web.xml文件中以监听器的形式加载spring的笔记

来源:互联网 发布:微信手机营销源码 编辑:程序博客网 时间:2024/06/06 00:41
 <listener>  <listener-class>   org.springframework.web.context.ContextLoaderListener  </listener-class> </listener> <context-param>  <param-name>contextConfigLocation</param-name>  <param-value>classpath:spring/applicationContext.xml</param-value> </context-param> <context-param/> 节点配置contextConfigLocation 属性是为了让ContextLoaderListener  找到Spring 上下文的位置并加载它,如果不指定contextConfigLocation,ContextLoaderListener 会到/WEB-INF/目录下找applicationContext.xml 来加载。 <listener/> 节点上配了ContextLoaderListener。它实现了ServletContextListener 接口, 所以web server 启动时ContextLoaderListener 能读取到ServletContext,也就能通过 <context-param/>指定的Spring 上下文的路径来找到上下文并加载它。


 

0 0
原创粉丝点击