Reputation: 1669
In the Spring Reference manual:
In the Web MVC framework, each DispatcherServlet has its own WebApplicationContext, which inherits all the beans already defined in the root WebApplicationContext.
What is root application context? How is it initialized? How does dispatcher servlet's web application context inherit them ie mechanism?
Upvotes: 1
Views: 215
Reputation: 841
The application context created by the DispatcherServlet inherits the application context created from the configuration files added to the web.xml file with the contextConfigLocation context-param:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:config1.spring.xml,
classpath:config2.spring.xml,
WEB-INF/config3.spring.xml,
</param-value>
</context-param>
From the config above, an application context is created containing all the beans specified on config1, config2 and config3 (including any annotation scanning for example). The application context from the DispatcherServlet inherits from this one.
Upvotes: 1