What is <context-param>
in web.xml
? Why do we use it?
For instance, what does the following do?
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet-servlet.xml</param-value>
</context-param>
In a spring web application, contextConfigLocation
context param gives the location of the root context.
Your config is strange, for a spring-mvc application, because by default, servletname-servlet.xml
(where servletname
is the name of a DispatcherServlet
servlet) is the child application context for the servlet.
What is current (and recommended by Spring documentation) is to have a root context that will contain the model layer (service, persistence and business beans) and a servlet context that will contain the controller and view layer (controller, view resolvers, interceptors). The rule is that bean in servlet context can use beans of root context but the reciprocal is false.
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