Reputation: 883
In web.xml
we have context parameter set named contextConfigLocation
and defined as shown in the below code:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/root-context.xml</param-value>
</context-param>
Also the same parameter is set in the Dispatch Servlet as shown below
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
What is the difference between these two contextConfigLocation
s ?
Upvotes: 2
Views: 2384
Reputation: 539
So basically we control Visibility (not scope ) of Beans by having different context-config files
Upvotes: 2
Reputation: 11926
There are two types of contexts:
Root context (Super)
Own (child) servlet context (Sub)
As generic application contexts, web application contexts are hierarchical. There is a single root context per application, while each servlet in the application (including a dispatcher servlet in the MVC framework) has its own child context.
Upvotes: 1
Reputation: 635
The fist setting applies globally, whilst second setting is private and exclusive to the "spring" servlet.
Upvotes: 2