参考:http://blog.youkuaiyun.com/zndxlxm/article/details/8711626
http://blog.youkuaiyun.com/sapphire_aling/article/details/6069764
在web.xml里配置Listener
<listener >
<listener-class > org.springframework.web.context.ContextLoaderListener <listener-class >
</listener >
如果在web.xml里给该Listener指定要加载的xml,如:
<listener >
<listener-class > org.springframework.web.context.ContextLoaderListener <listener-class >
</listener >
<context-param>
<param-name>contextConfigLocation</param-name> <!----定义了要装入spring的配置文件------->
<param-value>classpath:spring-beans-application.xml</param-value><!---如果没有指定的话,默认会去/WEB-INF/下加载applicationContext.xm---->
</context-param>
如果想装入多个配置文件,可以再<param-value>标记中用逗号分隔,如下:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring_gpay/*.xml,classpath*:spring_gpay/${DWENV}/*.xml,classpath*:framework_spring/*.xml</param-value>
</context-param>