原博文补充: web.xml配置中ContextLoaderListener和DispatcherServlet的区别: - ContextLoaderListener是在我们的web容器启动的时候启

web.xml配置中ContextLoaderListener和DispatcherServlet的区别:

- ContextLoaderListener是在我们的web容器启动的时候启动的,默认会加载/WEB-INF/下面的applicationContext.xml文件。并创建一个WebApplicationContext容器。
- DispatcherServlet是在我们第一次访问我们的应用的时候创建的。这时候它默认会将配置在/WEB-INF下面的<servlet-name>-servlet.xml配置文件,然后也创建一个WebApplicationContext。这个WebApplicationContext将之前ContextLoaderListener创建的容器作为父容器,因此在父容器中配置的所有Bean都能够被注入到子容器中。


原博文补充: web.xml配置中ContextLoaderListener和DispatcherServlet的区别: - ContextLoaderListener是在我们的web容器启动的时候启