classpath 和 classpath*的 区别:

classpath只会到你指定的class路径中查找找文件
classpath*不仅包含class路径,还包括jar文件中(class路径)进行查找.

举个简单的例子,若web.xml中是这么定义的:

  1. <context-param>
  2. <param-name>contextConfigLocation</param-name>
  3. <param-value>classpath*:META-INF/spring/applicationContext.xml</param-value>
  4. </context-param>
  5. <listener>
  6. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  7. </listener>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

那么在META-INF/spring这个文件夹底下的所有applicationContext.xml都会被加载到上下文中,这些包括META-INF/spring文件夹底下的 applicationContext.xml,META-INF/spring的子文件夹的applicationContext.xml以及jar中的applicationContext.xml。

而若在web.xml中定义的是:

  1. <context-param>
  2. <param-name>contextConfigLocation</param-name>
  3. <param-value>classpath:META-INF/spring/applicationContext.xml</param-value>
  4. </context-param>
  5. <listener>
  6. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  7. </listener>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

那么只有META-INF/spring底下的applicationContext.xml会被加载到上下文中。

classpath 和 classpath*的 区别:的更多相关文章

  1. web.xml 配置中classpath: 与classpath*:的区别

    首先 classpath是指 WEB-INF文件夹下的classes目录 解释classes含义: 1.存放各种资源配置文件 eg.init.properties log4j.properties s ...

  2. classpath: 和classpath*:的区别

    classpath本质是jvm的根路径,jvm获取资源都是从该根路径下找的,注意这个根路径是个逻辑路径,并不是磁盘路径.比如两个jar包的路径是/a/a.jar和/b/b.jar,但是用classpa ...

  3. 在web.xml中classpath和classpath*的区别

    classpath 和 classpath* 区别: classpath:只会到你指定的class路径中查找找文件; classpath*:不仅包含class路径,还包括jar文件中(class路径) ...

  4. WEB项目web.xml文件中classpath: 跟classpath*:使用的区别

    引用一篇很不错的文章:http://blog.csdn.net/wxwzy738/article/details/16983935 首先 classpath是指 WEB-INF文件夹下的classes ...

  5. 【转载】Spring加载resource时classpath*:与classpath:的区别

    免责声明:     本文转自网络文章,转载此文章仅为个人收藏,分享知识,如有侵权,请联系博主进行删除.     原文作者:kyfxbl     原文地址: spring配置中classpath和cla ...

  6. web.xml中classpath:和classpath*: 有什么区别?

    web.xml中classpath:和classpath*:     IccBoY applicationContext.xml 配置文件的存放位置 web.xml中classpath:和classp ...

  7. Spring配置中的"classpath:"与"classpath*:"的区别研究(转)

    Spring配置中的"classpath:"与"classpath*:"的区别研究(转)   概念解释及使用场景: classpath是指WEB-INF文件夹下 ...

  8. 转:web.xml 配置中classpath: 与classpath*:的区别

    原文链接:web.xml 配置中classpath: 与classpath*:的区别 引用自:http://blog.csdn.net/wxwzy738/article/details/1698393 ...

  9. web.xml 配置中classpath: 与classpath*:的区别——(十一)

    首先 classpath是指 WEB-INF文件夹下的classes目录 解释classes含义: 1.存放各种资源配置文件 eg.init.properties log4j.properties s ...

  10. Spring配置中的"classpath:"与"classpath*:"的区别研究

    概念解释及使用场景: classpath是指WEB-INF文件夹下的classes目录. 通常我们一般使用这种写法实在web.xml中,比如spring加载bean的上下文时,如下: <!--系 ...

随机推荐

  1. Django-model_form

    ModelForm a. class Meta: model, # 对应Model的 fields=None, # 字段 exclude=None, # 排除字段 labels=None, # 提示信 ...

  2. Django+uwsgi+nginx+angular.js项目部署

    这次部署的前后端分离的项目: 前端采用angular.js,后端采用Django(restframework),他俩之间主要以json数据作为交互 Django+uwsgi的配置可以参考我之前的博客: ...

  3. 按照HashMap中value值进行排序

    import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; ...

  4. hdu 1413 文件系统

    hdu   1413   文件系统         题目链接:pid=1413" target="_blank">http://acm.hdu.edu.cn/sho ...

  5. Kotlin基本语法笔记之函数、变量的定义及null检测

    定义函数 fun sum(a: Int, b: Int): Int { return a + b } 该函数中两个参数的类型都是Int,返回类型是Int 也可以做如下简化 fun sum(a: Int ...

  6. 第三章 Java 的基本程序设计结构

    1.Java基本数据类型 Java中一共有8种基本数据类型. 4种整形:int-4字节.long-8字节.short-2字节.byte-1字节 2中浮点型:float-4字节.double-8字节 1 ...

  7. Struts使用锚

    <a href="exam/ExaminationTrainAction_examTrainDisp#an_${id}"><div id="${id}& ...

  8. Oracle查询正在执行的SQL语句

    查看 Oracle 正在执行的 sql 语句以及发起的用户 SELECT b.sid oracleID, b.username 用户名, b.serial#, paddr, sql_text 正在执行 ...

  9. Ubuntu下声卡驱动解决方法alsa

    一.首先介绍一下什么是ALSA : Advanced Linux Sound Architecture 的简称为 ALSA ,译成中文的意思是先进的Linux声音架构(这是google翻译的):一谈到 ...

  10. JavaWeb项目里面的路径获取方法总结

    仅为资源搬运,个人还未充分理解... request.getRealPath不推荐使用request.getRealPath("") 这个方法已经不推荐使用了 request.ge ...