It's simple. Remember that the parameter area has two types: param parameter and init parameter. All you need is all the dependencies that must be initialized before loading the child context. Here DBbuildServletDispatcher should be initialized in the parent context, i.e. ApplicationContext , and AppServletDispatcher be WebApplicationContext , which is the child context of the application context
<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/spring/DBbuildServletDispatcher.xml </param-value> </context-param> <servlet> <servlet-name>firstServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/AppServletDispatcher.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>my-servlet</servlet-name> <url-pattern>/abc/* </url-pattern> </servlet-mapping>
The first part with the context parameter loads the context file and creates the ApplicationContext. The second part defines the WebApplicationContext. WebApplicationContextUtils can also be used here .
hi.nitish
source share