1. web.xml中classpath:和classpath*:  有什么区别?
  2. classpath:只会到你的class路径中查找找文件;
  3. classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找.
  4. 存放位置:
  5. 1:src下面
  6. 需要在web.xml中定义如下:
  7. <context-param>
  8. <param-name>contextConfigLocation</param-name>
  9. <param-value>classpath:applicationContext.xml</param-value>
  10. < /context-param>
  11. 2:WEB-INF下面
  12. 需要在web.xml中定义如下:
  13. <context-param>
  14. <param-name>contextConfigLocation</param-name>
  15. <param-value>WEB-INF/applicationContext*.xml</param-value>
  16. < /context-param>
  17. web.xml 通过contextConfigLocation配置spring 的方式
  18. SSI框架配置文件路径问题:
  19. struts2的 1个+N个 路径:src+src(可配置) 名称: struts.xml + N
  20. spring 的 1个 路径: src 名称: applicationContext.xml
  21. ibatis 的 1个+N个 路径: src+src(可配置) 名称: SqlMapConfig.xml + N
  22. 部署到tomcat后,src目录下的配置文件会和class文件一样,自动copy到应用的 classes目录下
  23. spring的 配置文件在启动时,加载的是web-info目录下的applicationContext.xml,
  24. 运行时使用的是web-info/classes目录下的applicationContext.xml。
  25. 配置web.xml使这2个路径一致:
  26. <context-param>
  27. <param-name>contextConfigLocation</param-name>
  28. <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
  29. < /context-param>
  30. 多个配置文件的加载
  31. <context-param>
  32. <param-name>contextConfigLocation</param-name>
  33. <param-value>
  34. classpath*:conf/spring/applicationContext_core*.xml,
  35. classpath*:conf/spring/applicationContext_dict*.xml,
  36. classpath*:conf/spring/applicationContext_hibernate.xml,
  37. classpath*:conf/spring/applicationContext_staff*.xml,
  38. classpath*:conf/spring/applicationContext_security.xml
  39. classpath*:conf/spring/applicationContext_modules*.xml
  40. classpath*:conf/spring/applicationContext_cti*.xml
  41. classpath*:conf/spring/applicationContext_apm*.xml
  42. </param-value>
  43. </context-param>
  44. contextConfigLocation 参数定义了要装入的 Spring 配置文件。
  45. 首先与Spring相关的配置文件必须要以"applicationContext-"开头,要符合约定优于配置的思想,这样在效率上和出错率上都要好很多。
  46. 还有最好把所有Spring配置文件都放在一个统一的目录下,如果项目大了还可以在该目录下分模块建目录。这样程序看起来不会很乱。
  47. 在web.xml中的配置如下:
  48. Xml代码
  49. <context-param>
  50. < param-name>contextConfigLocation</param-name>
  51. < param-value>classpath*:**/applicationContext-*.xml</param-value>
  52. < /context-param>
  53. "**/"表示的是任意目录;
  54. "**/applicationContext-*.xml"表示任意目录下的以"applicationContext-"开头的XML文件。
  55. 你自己可以根据需要修改。最好把所有Spring配置文件都放在一个统一的目录下,如:
  56. <!-- Spring 的配置 -->
  57. <context-param>
  58. <param-name>contextConfigLocation</param-name>
  59. <param-value>classpath:/spring/applicationContext-*.xml</param-value>
  60. < /context-param>

applicationContext.xml存放的位置的更多相关文章

  1. applicationContext.xml的文件位置就可以有两种默认实现

    ContextLoaderListener的作用就是启动Web容器时,自动装配ApplicationContext的配置信息.因为它实现了ServletContextListener这个接口,在web ...

  2. applicationContext.xml文件放置位置不同而导致的jUnit测试的时候路径的不同

    如果applicationContext.xml文件放置在src下面的的时候使用jUint测试的时候编写的路径应该是这样的: @Test public void testFindByPage() { ...

  3. 转:applicationContext.xml文件放置位置不同而导致的jUnit测试的时候路径的不同

    如果applicationContext.xml文件放置在src下面的的时候使用jUint测试的时候编写的路径应该是这样的: @Test public void saveTest() { Applic ...

  4. Spring中,applicationContext.xml 配置文件在web.xml中的配置详解

    一.首先写一下代码结构. 二.再看web.xml中的配置情况. <?xml version="1.0" encoding="UTF-8"?> < ...

  5. spring-mvc.xml 和 application-context.xml的区别

    转自:https://www.cnblogs.com/binlin1987/p/7053016.html application-context.xml是全局的,应用于多个serverlet,配合li ...

  6. 【Spring】如何配置多个applicationContext.xml文件

    在web.xml中通过contextConfigLocation配置spring 开发Java Web程序,使用ssh架构时,默认情况下,Spring的配置文件applicationContext.x ...

  7. applicationContext.xml 配置文件的存放位置

    eb.xml中classpath:和classpath*:  有什么区别? classpath:只会到你的class路径中查找找文件; classpath*:不仅包含class路径,还包括jar文件中 ...

  8. [JavaEE] applicationContext.xml配置文件使用合集

    配置实例 – 1 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http ...

  9. applicationContext.xml中的使用${}是代表什么意思?

    在applicationContext.xml文件中,使用 ${xxx} 表示的是:调用某个变量,该变量的名称就是{xxx}里面的"xxx".   例如:在applicationC ...

随机推荐

  1. 物联网操作系统HelloX V1.78测试版正式发布

    经过HelloX开发团队近四个月的努力,在HelloX V1.77版本基础上,增加许多功能特性,并对V1.77版本的一些特性进行了进一步优化之后,正式形成HelloX V1.78测试版本,经相对充分的 ...

  2. Java [Leetcode 290]Word Pattern

    题目描述: Given a pattern and a string str, find if str follows the same pattern. Here follow means a fu ...

  3. LeetCode: divideInteger

    Title: Divide two integers without using multiplication, division and mod operator. If it is overflo ...

  4. 【转】pdf 中如何把几页缩小成一页打印

    我用的是Foxit PDF Reader,可以这样设置:文件-打印-打印处理下的页面排列选择“在每张纸上放置多页”-选择每页版数即可. 如果你用的是Adobe Reader,也可以自己找一下,看是否有 ...

  5. ECSHOP v2.5数据库字典

    ECSHOP v2.5 数据库字典 ECSHOP R&D Team 2007年4月16日 商品相关表 商品分类表 category 此表用来维护商品分类信息 字段名 字段描述 字段类型 默认值 ...

  6. jdbc:oracle:thin:@192.168.3.98:1521:orcl(详解)

    整理自互联网 一. jdbc:oracle:thin:@192.168.3.98:1521:orcljdbc:表示采用jdbc方式连接数据库oracle:表示连接的是oracle数据库thin:表示连 ...

  7. POJ 2253 Difference of Clustering

    题意:给出一堆点,求从起点到终点的所有通路中相邻点的距离的最大值的最小值.(意思就是自己百度吧……) 解法:用相邻点的最大值作为权值代替路径的距离跑最短路或者最小生成树.然后我写了一个我以为是优化过的 ...

  8. equals(),hashcode()方法详解

    Java中的equals方法和hashCode方法是Object中的,所以每个对象都是有这两个方法的,有时候我们需要实现特定需求,可能要重写这两个方法,今天就来介绍一些这两个方法的作用. equals ...

  9. delphi7在win7系统如何安装spcomm控件

    1.先准备好串口控件SPCOMM,例如把它放在F盘的工具安装文件夹下,等一下加载时需要用到. 2.打开delphi7软件. 3.按下上面的Component>Install  Component ...

  10. C++实现网格水印之调试笔记(三)—— 初有结果

    错误: error C2338: THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD 这种错误 ...