在web.xml里配置Listener
如果在web.xml里给该Listener指定要加载的xml,如:
xml代码如下:
<!-- spring config -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
则会去加载相应的xml,而不会去加载/WEB-INF/下的applicationContext.xml。
但是,如果没有指定的话,默认会去/WEB-INF/下加载applicationContext.xml。
*******************************************************************************************
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/resource/spring/**/*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
本文介绍如何在web.xml中配置Spring的ContextLoaderListener,并说明了如何指定加载的配置文件路径,包括默认加载路径及自定义路径。
861

被折叠的 条评论
为什么被折叠?



