公司的考勤系统程序,有5个spring配置文件:bean-edu.xml,bean-pub.xml,db-edu.xml,db-pub.xml,timer-system.xml,均放置于src目录下,在web.xml中配置这些文件的代码如下:

  1. <context-param>
  2. <param-name>contextConfigLocation</param-name>
  3. <param-value>classpath:/db-pub.xml,
  4. classpath:db-edu.xml,
  5. classpath:bean*.xml,
  6. classpath*:timer-system.xml
  7. </param-value>
  8. </context-param>

注意:部署程序启动tomcat之后,log4j显示出  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from class path resource [db-pub.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from class path resource [db-edu.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from file [E:\apache-tomcat-6.0.33-windows-x86\apache-tomcat-6.0.33\webapps\DigitalCampus\WEB-INF\classes\bean-edu.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from file [E:\apache-tomcat-6.0.33-windows-x86\apache-tomcat-6.0.33\webapps\DigitalCampus\WEB-INF\classes\bean-pub.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  -  Loading XML bean definitions from URL [file:/E:/apache-tomcat-6.0.33-windows-x86/apache-tomcat-6.0.33/webapps/DigitalCampus/WEB-INF/classes/timer-system.xml]

  1. <context-param>
  2. <param-name>contextConfigLocation</param-name>
  3. <param-value>classpath:/db-pub.xml,
  4. classpath:db-edu.xml,
  5. classpath*:bean*.xml,
  6. /WEB-INF/classes/timer-system.xml
  7. <!--  classpath*:timer-system.xml-->
  8. </param-value>
  9. </context-param>

[main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from class path resource [db-pub.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from class path resource [db-edu.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from file [E:\apache-tomcat-6.0.33-windows-x86\apache-tomcat-6.0.33\webapps\DigitalCampus\WEB-INF\classes\bean-edu.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from file [E:\apache-tomcat-6.0.33-windows-x86\apache-tomcat-6.0.33\webapps\DigitalCampus\WEB-INF\classes\bean-pub.xml]  [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader  - Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/timer-system.xml] 
根据以上两个例子:  1 classpath和classpath*的区别是:前者from class path resource,后者from URL。classpath:只会到你的class路径中查找找文件;  classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找.  2 带不带有/,没有区别。  3 bean*.xml查找的是以bean开头的配置文件,from file  4 classpath*:bean*.xml 为from file.  5   /WEB-INF/classes/timer-system.xml 为from ServletContext resource。

另外:  "**/" 表示的是任意目录;  "**/applicationContext-*.xml" 表示任意目录下的以"applicationContext-"开头的XML文件。  程序部署到tomcat后,src目录下的配置文件会和class文件一样,自动copy到应用的 WEB-INF/classes目录下

web.xml中通过contextConfigLocation的读取spring的配置文件的更多相关文章

  1. 【转】web.xml中的contextConfigLocation在spring中的作用

    一.spring中如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocation参数,Spring会使用这个参数去加载所有逗号分隔的xml文件,如果没有这个参数,sp ...

  2. (转)web.xml中的contextConfigLocation在spring中的作用

    (转)web.xml中的contextConfigLocation在spring中的作用   一.Spring如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocat ...

  3. web.xml中的contextConfigLocation在spring中的作用

    在web.xml中通过contextConfigLocation配置spring, contextConfigLocation参数定义了要装入的 Spring 配置文件.默认会去/WEB-INF/下加 ...

  4. web.xml中的contextConfigLocation的作用

    在web.xml中通过contextConfigLocation配置spring,contextConfigLocation 参数定义了要装入的 Spring 配置文件. 如果想装入多个配置文件,可以 ...

  5. 在web.xml中通过contextConfigLocation配置spring

    <context-param>         <param-name>contextConfigLocation</param-name>         < ...

  6. web.xml中contextConfigLocation的作用(转)

    原文地址:http://blog.csdn.net/zhangliao613/article/details/6289114 原文格式较乱,此处略作整理.内容未变. 在web.xml中使用contex ...

  7. spring 和springmvc 在 web.xml中的配置

    (1)问题:如何在Web项目中配置Spring的IoC容器? 答:如果需要在Web项目中使用Spring的IoC容器,可以在Web项目配置文件web.xml中做出如下配置: <!-- Sprin ...

  8. 使用Spring时web.xml中的配置

    使用Spring时web.xml中的配置: <?xml version="1.0" encoding="UTF-8"?> <web-app x ...

  9. web.xml中配置Spring中applicationContext.xml的方式

    2011-11-08 16:29 web.xml中配置Spring中applicationContext.xml的方式 使用web.xml方式加载Spring时,获取Spring applicatio ...

随机推荐

  1. 初始Django—Hello world

    1. 准备环境 > python -V Python > pip -V pip from c:\python3\lib\site-packages\pip (python 3.7) > ...

  2. CF57C Array

    题目传送门 题目大意(摘自洛谷) 描述 对于长度为n的数组A,A中只包含从1到n的整数(可重复).如果A单调不上升或单调不下降,A就可称为美丽的. 找出在长度为n时,有几个美丽的A. 输入 一个整数n ...

  3. Vulnhub 靶场 Os-hackNos WP

    About Os-hackNos 描述 Difficulty : Easy to Intermediate Flag : 2 Flag first user And second root Learn ...

  4. css3笔记系列-3.css中的各种选择器详解,不看后悔系列

    点击上方蓝色字体,关注我 最详细的css3选择器解析 ​ 选择器是什么? 比较官方的解释:在 CSS 中,选择器是一种模式,用于选择需要添加样式的元素. 最常见的 CSS 选择器是元素选择器.换句话说 ...

  5. DRF之restful规范、Postman接口测试

    一. DRF简介 Django REST框架是一个功能强大且灵活的工具包,用于构建Web API. 使用REST框架的一些原因: 该网站可浏览API是你的开发人员一个巨大的可用性胜利. 身份验证策略包 ...

  6. Django CBV加装饰器、Django中间件、auth模块

    一. CBV加装饰器 在视图层中,基于函数的视图叫FBV(function base views),基于类的视图叫CBV(class base views).当需要用到装饰器时,例如之前的基于Cook ...

  7. canvas.toDataURL()报错的解决方案全都在这了

    报错详尽信息 Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases ...

  8. python set() leetcode 签到820. 单词的压缩编码

    题目 给定一个单词列表,我们将这个列表编码成一个索引字符串 S 与一个索引列表 A. 例如,如果这个列表是 ["time", "me", "bell& ...

  9. Github标星过万,Python新手100天学习计划,这次再学不会算我输!

      作为目前最火也是最实用的编程语言,Python不仅是新手入门程序界的首选,也逐渐成为了从大厂到小厂,招牌需求list的必要一条. 当然,学Python这件事情,你可能也和文摘菌一样,已经下了一百次 ...

  10. 配置centOS下的Python

    Linux下Python版本升级: 1. 首先确认Linux操作系统中自带的python 版本时候与自己所需要的版本一致 所有的python版本都在https://www.python.org/ftp ...