Spring中WEB.xml配置总结
来源:互联网 发布:中标麒麟 软件源 编辑:程序博客网 时间:2024/05/16 10:39
1. 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>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/spring/applicationContext-*.xml</param-value>
</context-param>
web.xml中classpath:和classpath*:, 有什么区别?
classpath:只会到你的class路径中查找找文件;
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>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/spring/applicationContext-*.xml</param-value>
</context-param>
web.xml中classpath:和classpath*:, 有什么区别?
classpath:只会到你的class路径中查找找文件;
classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找.
在web.xml里配置Listener
xml 代码如下:
< listener >
<listener-class> org.springframework.web.context.ContextLoaderListener< listener-class>
< /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。
0 0
- Spring中WEB.xml配置总结
- web.xml中配置spring
- web.xml中配置Spring
- Spring 配置 工程Web.xml中encodingFilter
- spring mvc中web.xml的配置
- 在web.xml文件中配置Spring
- web.xml中spring/springmvc配置详解
- 在web.xml中配置Spring
- web.xml中配置spring的几种方式 spring spring web.xml
- web.xml中配置spring的几种方式 spring spring web.xml
- web.xml配置总结
- web.xml配置总结
- web.xml配置总结
- web.xml配置总结
- Spring XML配置总结
- web.xml中servlet, spring, filter, listenr的配置
- web.xml中配置Spring的OpenSessionInViewFilter的作用
- Spring 中在web.xml的常用配置
- [leetcode] 357. Count Numbers with Unique Digits
- 谈谈网络编程中应用层(基于TCP/UDP)的协议设计 [帧设计]
- 一个iOS模块化开发解决方案
- CompoundLayout
- 欧拉计划(鱼C论坛)@20161107
- Spring中WEB.xml配置总结
- jdbc调用存储过程
- Android 下插件补丁的开发框架
- 2345.com 强制占用主页清理
- example
- 使用pull方法解析Xml文件(省市县Xml)
- 将Android项目发布到Jcenter
- java实现多线程selenium造数据
- Linux启动过程