Q: How do I get a resource from the servletContext or applicationContext from a service?
To get the ApplicationContext, have your service implement ApplicationContextAware and declare an 'applicationContext' field. Then from within your service:
def resource = applicationContext.getResource("foo")
Accessing the Servlet Context:
import org.codehaus.groovy.grails.web.context.ServletContextHolder as SCHdef servletContext = SCH.servletContext
but mey servletContext is null... what is wrong??
ReplyDelete