<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml,/WEB-INF/daoContext.xml</param-value>
</context-param>
<!-- 加载spring配置文件的路径 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring/applicationcontext-businessmanage.xml,
classpath:spring/applicationcontext-channelmanage.xml,
classpath:spring/applicationcontext-datasource.xml,
classpath:spring/applicationcontext-goods.xml,
classpath:spring/applicationcontext-logmanage.xml,
classpath:spring/applicationcontext-plugin.xml,
classpath:spring/applicationcontext-resourcemanage.xml,
classpath:spring/applicationcontext-publishmanage.xml,
classpath:spring/applicationcontext-sitemanage.xml,
classpath:spring/applicationcontext-syncmanage.xml,
classpath:spring/applicationcontext-systemmanage.xml,
classpath:spring/applicationcontext-webmanage.xml,
classpath:spring/applicationcontext-weathermange.xml,
classpath:spring/applicationcontext-businessrecommendmanage.xml,
classpath:spring/applicationcontext-greetingmanage.xml,
classpath:spring/applicationcontext-portalurlmanage.xml,
classpath:spring/applicationcontext-product.xml,
classpath:spring/applicationcontext-channelTypemanage.xml,
classpath:spring/applicationcontext-busreccontent.xml,
classpath:spring/applicationcontext-recschedule.xml,
classpath:spring/applicationcontext-loginmanage.xml,
classpath:spring/applicationcontext-controlMapManage.xml,
classpath:spring/applicationcontext-terminal.xml,
classpath:spring/applicationcontext-daf.xml,
classpath:spring/applicationcontext-emergency.xml,
classpath*:conf/rights/appContextService.xml,
classpath*:conf/rights/action-beans-rights.xml,
classpath:spring/applicationcontext-emergencyPublishCode.xml,
classpath:spring/applicationcontext-publishDomain.xml,
classpath:spring/applicationcontext-templatemanage.xml,
classpath:spring/applicationcontext-publishGroup.xml,
classpath:spring/applicationcontext-publishTaskmanage.xml,
classpath:spring/applicationcontext-portalVersion.xml,
classpath:spring/applicationcontext-review.xml,
classpath:spring/applicationcontext-zone.xml,
classpath:spring/applicationcontext-virtualNetwork.xml,
classpath:spring/applicationcontext-widget.xml,
classpath:spring/applicationcontext-hotel.xml,
classpath:spring/applicationcontext-media.xml,
classpath:spring/applicationcontext-application.xml,
classpath:spring/applicationcontext-node.xml,
classpath:spring/applicationcontext-marquee.xml,
classpath:spring/applicationcontext-schedule.xml,
classpath:spring/applicationcontext-recommendPosition.xml,
classpath:spring/applicationcontext-recommendImage.xml,
classpath:spring/applicationcontext-packetTask.xml,
classpath:spring/applicationContext-operation.xml,
classpath:spring/applicationContext-service.xml,
classpath:spring/applicationcontext-businessdatatype.xml,
classpath:spring/applicationcontext-rolemanage.xml,
classpath:spring/applicationcontext-assetImage.xml,
classpath:spring/applicationContext-display.xml,
classpath:spring/applicationcontext-report.xml
</param-value>
</context-param>
web.xml 通过contextConfigLocation配置spring 的方式
SSI框架配置文件路径问题:
struts2的 1个+N个
spring 的 1个
ibatis 的 1个+N个
部署到tomcat后,src目录下的配置文件会和class文件一样,自动copy到应用的 classes目录下
spring的 配置文件在启动时,加载的是web-info目录下的applicationContext.xml,
运行时使用的是web-info/classes目录下的applicationContext.xml。
配置web.xml使这2个路径一致:
<context-param>
</context-param>
多个配置文件的加载
<context-param>
contextConfigLocation 参数定义了要装入的 Spring 配置文件。
首先与Spring相关的配置文件必须要以"applicationContext-"开头,要符合约定优于配置的思想,这样在效率上和出错率上都要好很多。
还有最好把所有Spring配置文件都放在一个统一的目录下,如果项目大了还可以在该目录下分模块建目录。这样程序看起来不会很乱。
在web.xml中的配置如下:
Xml代码
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:**/applicationContext-*.xml</param-value>
</context-param>
"**/"表示的是任意目录;
"**/applicationContext-*.xml"表示任意目录下的以"applicationContext-"开头的XML文件。
你自己可以根据需要修改。最好把所有Spring配置文件都放在一个统一的目录下,如:
<!-- Spring 的配置 -->
<context-param>
</context-param>
web.xml中classpath:和classpath*:, 有什么区别?
classpath:只会到你的class路径中查找找文件;
classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找