在web.xml中通过contextConfigLocation配置spring,
contextConfigLocation参数定义了要装入的 Spring 配置文件。默认会去/WEB-INF/下加载applicationContext.xml。
如果想装入多个配置文件,可以在 <param-value>标记中用逗号作分隔符或通配符。
在web.xml里配置Listener
web.xml 代码如下:
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/app-*.xml</param-value> </context-param>
app-context.xml
<context:component-scan base-package="com.xdt.ibs" />
本文介绍如何在web.xml中配置Spring的ContextLoaderListener监听器及contextConfigLocation参数来加载多个Spring配置文件,支持使用通配符匹配文件。
4万+

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



