<!-- 载入Spring ApplicationContext --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
ContextLoaderListener的作用就是启动Web容器时,自动装配spring的ApplicationContext的配置信息。
<listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener>
官方文档:
If you use a Servlet 2.4+ web container, with requests processed outside of Spring's DispatcherServlet (for example, when using JSF or Struts), you need to add the following javax.servlet.ServletRequestListener
to the declarations in your web applications web.xml
file:
<web-app> ... <listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener> ... </web-app>
意思是:如果你使用Servlet 2.4及以上的web容器,请求处理Spring的DispatcherServlet之外的(例如,当使用JSF或Struts),你需要添加以下javax.servlet.ServletRequestListener声明在web应用程序的web.xml文件中