To sum up:
There are two types of Spring WebApplicationContext loading: ContextLoaderListener and DispatcherServlet. In web.xml configuration, what is the difference between ContextLoaderListener and DispatcherServlet?
1 ContextLoaderListener
is started when our web container starts, and the applicationContext.xml file under /WEB-INF/ will be loaded by default. And create a WebApplicationContext container, which is the Root WebApplicationContext of the web.
2 DispatcherServlet
is created when we first visit our application. At this time, it will configure the <servlet-name>-servlet.xml configuration file under /WEB-INF by default, and then also create a WebApplicationContext. This WebApplicationContext has the container created by the ContextLoaderListener as the parent container.
Therefore, all beans configured in the parent container can be injected into the child container; beans in the child container cannot be referenced and used by the parent container.
You can refer to another article:
http://angie.iteye.com/blog/2334956
Difference between DispatcherServlet and ContextLoaderListener
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326992135&siteId=291194637
Recommended
Ranking