Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is context param in web.xml?

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>
like image 272
Arul Murugan Avatar asked Jan 10 '23 01:01

Arul Murugan


1 Answers

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.

like image 120
Serge Ballesta Avatar answered May 21 '23 01:05

Serge Ballesta