`

web.xml中classpath与classpath*区别

 
阅读更多

首先 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会被加载到上下文中。

 

参考:

http://blog.sina.com.cn/s/blog_76786df301016al4.html

http://scnulh.iteye.com/blog/1318628

http://blog.csdn.net/spirit23k/article/details/8699209

分享到:
评论

相关推荐

    web.xml中如何设置配置文件的加载路径实例详解

    web.xml中如何设置配置文件的加载路径实例详解 web应用程序通过Tomcat等容器启动时,会首先加载web.xml文件,通常我们工程中的各种配置文件,如日志、数据库、spring的文件等都在此时被加载,下面是两种常用的配置...

    ssh框架在application.xml中配置数据源所需jar

    - dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation"). --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...

    企业人力资源管理项目SSH+EXT+MySQL+MD5

    在web.xml的display-name标签与welcome-file-list标签中加入一下代码 struts2 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter struts2 /* org.springframework.web.context....

    负载均衡软件

    软件负载均衡, 为没有部署硬件负载均衡器的应用提供负载均衡功能;已打包成war文件; 1. 系统提供完整的日志信息(log4j.properties); 2. 系统提供节点连通性检查开关和...5. web.xml配置文件位置在/WEB-INF/web.xml

    ehcahe页面缓存详细内容

    2.将ehcache.xml放入能加载到classpath中的任意包中,不能放入WEB-INF中(其详细配置参数代表含义已经注释) 3.在工程中web.xml配置过滤器 <filter-name>SimplePageCachingFilter <filter-class>...

    让Struts2可以从classpath及jar中查找jsp文件

    1、把两个类文件加入你的工程或者打包成jar。...4、注意:这个ResultType会在你的WEB-INF下面建立一个名为CLASSPATH-PAGES的文件夹,并将找到的jsp释放到这里。你可以改写这个类,从而在某个地方配置这一路径。

    基于java的企业级应用开发:Spring的核心容器.ppt

    通常会使用ContextLoaderListener来实现,此种方式只需要在web.xml中添加如下代码: <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:spring/applicationContext.xml ...

    Spring MVC Demo

    <param-value>classpath:applicationContext-*.xml <!--查找这里可以配置多个,用逗号分割或者用通配符*也就是第二行 <param-value>/WEB-INF/mvc.xml,/WEB-INF/mvc1.xml <param-value>/WEB-INF/mvc*.xml ...

    springweb3.0MVC注解(附实例)

    web.xml 中定义了一个名为 annomvc 的 Spring MVC 模块,按照 Spring MVC 的契约,需要在 WEB-INF/annomvc-servlet.xml 配置文件中定义 Spring MVC 模块的具体配置。annomvc-servlet.xml 的配置内容如下所示: <?xml...

    hello Spring

    │ web.xml │ └─lib commons-logging-1.1.3.jar spring-aop-3.2.4.RELEASE.jar spring-aspects-3.2.4.RELEASE.jar spring-beans-3.2.4.RELEASE.jar spring-context-3.2.4.RELEASE.jar spring-core-...

    基于java的企业级应用开发:Spring MVC的核心类和注解.ppt

    在使用时,只需将其配置在项目的web.xml文件中,其配置代码如下: <servlet> <servlet-name>springmvc</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> ...

    maven相关资料

    ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:/*.xml"); 二、ClassPathXmlApplicationContext[只能读放在web-info/classes目录下的配置文件]和FileSystemXmlApplicationContext的区别 ...

    Android购物网站源代码,安卓商城购物源码,安卓APP源码商业版

    │ │ AndroidManifest.xml │ │ proguard.cfg │ │ project.properties │ │ │ ├─.settings │ │ org.eclipse.jdt.core.prefs │ │ │ ├─assets │ ├─bin │ │ │ AndroidBookProject2.apk │ │ │...

    soccerLeague

    ............\....\...\.......\web.xml ............\....\web.war ............\etc ............\...\web ............\...\...\catalog.txt ............\...\...\web.xml ............\lib ..............

    BBS-CS_3_Tomcat4.rar

    BBS-CS是采用JSP+JavaBean+Servlet开发的一套网络虚拟社区系统。 运行平台: Liunx + JDK + Apache + Tomcat + MYSQL 或 Windows2000(WindowsNT、Windows98) + JDK + Apache + Tomcat + MYSQL...*.js(javascript文件)

    halloworld

    删改查11\.classpath ..........\.myhibernatedata ..........\.mymetadata ..........\.mystrutsdata ..........\.project ..........\.settings\.jsdtscope ..........\.........\org.eclipse.jdt.core....

    spring-simple-web:使用 Spring Framework 的简单 Web (WAR) 项目

    这个简单的例子演示了在 web 应用程序中使用的 Spring 容器,即org.springframework.web.context.WebApplicationContext Web 应用程序使用 Spring Web 侦听器初始化,例如web.xml org.springframework.web.context...

    生活轨迹SSH服务端

    -- <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value> --> <param-value>classpath:beans.xml <filter-name>struts2 <filter-class>org.apache.struts2...

    客户关系管理系统框架搭建(二)

    <value>classpath:hibernate.cfg.xml <!--4 创建事务管理器 aop切面--> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> ...

    SSH第7章上机.zip ACCP8.0

    <param-value>classpath*:applicationContext-*.xml <!-- 配置spring随web容器启动时就创建 --> <listener-class>org.springframework.web.context.ContextLoaderListener 在struts.xml中配置对象创建工具...

Global site tag (gtag.js) - Google Analytics