web.xml配置contextConfigLocation
来源:互联网 发布:js判断大于0的整数 编辑:程序博客网 时间:2024/06/16 01:06
web.xml中classpath:和classpath*: 有什么区别?
classpath:只会到你的class路径中查找找文件;
classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找.
有时候会用模糊匹配的方式配置多配置文件。
但是如果配置文件是在jar包里,模糊匹配就找不到了。可以用逗号隔开的方式配置多个配置文件。
如:
存放位置:
1:src下面
需要在web.xml中定义如下:
2:WEB-INF下面
需要在web.xml中定义如下:
web.xml 通过contextConfigLocation配置spring 的方式
SSI框架配置文件路径问题:
struts2的 1个+N个 路径:src+src(可配置) 名称: struts.xml + N
spring 的 1个 路径: src 名称: applicationContext.xml
ibatis 的 1个+N个 路径: src+src(可配置) 名称: SqlMapConfig.xml + N
部署到tomcat后,src目录下的配置文件会和class文件一样,自动copy到应用的 classes目录下
spring的 配置文件在启动时,加载的是web-info目录下的applicationContext.xml,
运行时使用的是web-info/classes目录下的applicationContext.xml。
配置web.xml使这2个路径一致:
多个配置文件的加载
contextConfigLocation 参数定义了要装入的 Spring 配置文件。
首先与Spring相关的配置文件必须要以"applicationContext-"开头,要符合约定优于配置的思想,这样在效率上和出错率上都要好很多。
还有最好把所有Spring配置文件都放在一个统一的目录下,如果项目大了还可以在该目录下分模块建目录。这样程序看起来不会很乱。
在web.xml中的配置如下:
Xml代码
"**/"表示的是任意目录;
"**/applicationContext-*.xml"表示任意目录下的以"applicationContext-"开头的XML文件。
你自己可以根据需要修改。最好把所有Spring配置文件都放在一个统一的目录下,如:
<!-- Spring 的配置 -->
- web.xml 配置 contextConfigLocation
- web.xml 配置 contextConfigLocation
- web.xml 配置 contextConfigLocation
- web.xml 配置 contextConfigLocation
- web.xml 配置 contextConfigLocation
- web.xml配置contextConfigLocation
- web.xml中配置contextConfigLocation参数作用
- web.xml中contextConfigLocation的配置方法
- web.xml 通过contextConfigLocation配置spring 的方式
- web.xml 通过contextConfigLocation配置spring 的方式
- web.xml 通过contextConfigLocation配置spring 的方式
- web.xml 通过contextConfigLocation配置spring 的方式(转)
- 在web.xml中通过contextConfigLocation配置spring
- web.xml中的contextConfigLocation的作用
- web.xml 通过 contextConfigLocation 配 spring 方式
- web.xml中contextConfigLocation的作用
- web.xml中的contextConfigLocation的作用
- web.xml中的contextConfigLocation的作用
- 得学习的C语言开源项目
- 06 MapReduce工作机制
- datePicker显示中文
- Spring+SpringMVC+MyBatis+easyUI整合优化篇(十)数据层优化-整合druid
- [BZOJ 4403]序列统计:Lucas定理
- web.xml配置contextConfigLocation
- Range Sum Query
- java.lang.UnsupportedOperationException: Required method destroyItem was not overridden
- 给某个。c单独添加DEBUG 编译选项
- 业务规则工具drools学习(一)drools简介和下载
- Ubuntu下添加开机启动项的2种方法
- 非阻塞socket下客户端connect + select简单demo
- android——PowerManagerService源码分析
- 二叉树的基本操作