I need get resource with method ApplicationContext.getResource() but how can I get ApplicationContext in bean class in web app?
edit: or any other method to get resource from classpath...
I need get resource with method ApplicationContext.getResource() but how can I get ApplicationContext in bean class in web app?
edit: or any other method to get resource from classpath...
Last edited by Juliusz; Jan 18th, 2011 at 06:42 AM.
i'm also intrested into that.. Have you found a solution ?
I digged that it should be helpful WebApplicationContext interface (it extends ApplicationContext interface).
To get this is static method getWebApplicationContext(ServletContext sc) of some util class: http://static.springsource.org/sprin...vletContext%29
parameter ServletContext is available from implementing ServletContextAware interface in bean class that use getWebApplicationContext(..)
edit: unfortunately servletContext in case ServletContextAware is equal null in constructor since I can't get Resource in bean constructor.
edit2: unfortunately WebApplicationContext is null after this in bean init-method: WebApplicationContext webappctx = WebApplicationContextUtils.getWebApplicationContex t(servletContext); although servletContext there is not null![]()
Last edited by Juliusz; Jan 18th, 2011 at 06:40 AM.
Please help...
You want to access the application context inside of a bean?
Isn't implementing ApplicationContextAware helps?
Amila Domingo