I need the context to ApplicationContext.xml ,which I provided in web.xml as
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
But I need a control for this in Controller class.
I tried many things including
WebApplicationContext ctx = ContextLoader.getCurrentWebApplicationContext();
but it doesnt help.
Easiest solution is to use getWebApplicationContext() of WebApplicationContextUtils:
Find the root WebApplicationContext for this web application, which is typically loaded via ContextLoaderListener.
See also getRequiredWebApplicationContext().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With