web.xml 配置中classpath: 与classpath*:的区别
来源:互联网 发布:ubuntu wine安装qq 编辑:程序博客网 时间:2024/05/18 10:34
引用一篇很不错的文章:http://blog.csdn.net/wxwzy738/article/details/16983935
首先 classpath是指WEB-INF文件夹下的classes目录
classpath 和 classpath* 区别:
classpath:只会到你指定的class路径中查找文件;
classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找.
举个简单的例子,在我的web.xml中是这么定义的:classpath*:META-INF/spring/application-context.xml
那么在META-INF/spring这个文件夹底下的所有application-context.xml都会被加载到上下文中,这些包括 META-INF/spring文件夹底下的 application-context.xml,META-INF/spring的子文件夹的application-context.xml以及 jar中的application-context.xml。
如果我在web.xml中定义的是:classpath:META-INF/spring/application-context.xml
那么只有META-INF/spring底下的application-context.xml会被加载到上下文中。
项目实践中用的比较多就是在web.xml文件中配置spring监听器,让它读取*.xml文件,加载其中的bean.
举例如下
首先:在ssh框架搭建好之后,在web.xml文件中进行如下配置
<!--系统自动加载文件 -->
这里使用的是classpath*:的形式
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:ssh2-*.xml</param-value>
</context-param>
<!--配置spring的context监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
在项目的.classpath文件中有如下的配置
补充:
1.)关于.classpath文件的查看可以去项目存放的位置(workplace)下查看,也可以在eclipse中navigator视图中进行查看
2.)navigator视图是在window---->show view----->other------>navigator中可以找到.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<!--系统默认的class文件加载路径,不能够删除-->
<classpathentry kind="src" path="src"/>
<!--自己新添加的class文件加载路径-->
<!--<classpathentry kind="src" path="config"/>-->
这里可以添加classpath的路径,例如我的配置文件路径时放在了与src同级的目录下,你也可以指定自己的文件存放路径.
项目启动时候,系统会依据.classpath文件中指定的src的路径依次查找所要加载的配置文件。并加载其中的bean.
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中“classpath” 与“classpath*”的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml配置中classpath:与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- web.xml 配置中classpath: 与classpath*:的区别
- 八皇后问题及其优化
- java线程基础知识
- Font Awesome插件的使用
- 没有OpenCV环境下运行OpenCV程序
- (19)版本控制
- web.xml 配置中classpath: 与classpath*:的区别
- 让ie7/8支持css3属性
- Andy的作业 (大数相乘)
- 网页爬取系列(一)爬取网页数据的一些小技巧
- 有用的JS(一)
- C# Enum,Int,String的互相转换
- HDU-1215
- Android之性能优化
- NOIP模拟 楼层