1. 在使用springmvc时需要配置得信息有两个,一个是spring-servlet.xml和applcation.xml:
        • 首先两个文件的的存放位置就有一点的不同(见下图),application.xml(是下图中的root-context.xml)是在spring文件夹下,而spring-servlet.xml(下图中的servlet-contextxml)是在更下一层目录中(appservlet)中。其实命名规则是可以随自己写,图中的命名规则和平时的就略有不同。
        • 他们的作用范围就更不一样了,spring-servlet.xml作用范围是controller级别的,作用范围是控制层的上下文。application.xml则是系统级别的。
        • 两个配置文件在web.xml:
          1. spring-servlet.xml是配置在标签:<servlet><init-param><param-vaule>/WEB-INF/spring/appServlet/servlet-context.xml</param-value></init-param></servlet>

             <servlet>
            <servlet-name>appServlet</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
            </servlet>
          2. application.xml中则是放在<content-param>/WEB-INF/spring/root-context.xml</param>中
            <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/root-context.xml</param-value>
            </context-param>  

以上是个人看一些博客和自己总结来的,觉得正确就拿去用!不正确的地方或可以指出来,谢谢!

有关spring-servlet.xml 和 application.xml的配置信息讲解(这两个配置信息的区别在哪里)的更多相关文章

  1. springmvc web.xml和application.xml配置详情(附:完整版pom.xml)

    web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="htt ...

  2. @Value取不到值引出的spring的2种配置文件applicationContext.xml和xxx-servlet.xml

    项目中经常会用到配置文件,定义成properties的形式比较常见,为了方便使用一般在spring配置文件中做如下配置: <context:property-placeholder ignore ...

  3. DispatcherServlet和ContextLoaderListener,还有spring+servlet3.0 无web.xml启动问题

    上篇提到: 关于spring +springmvc中两个spring应用上下文(DispatcherServlet和ContextLoaderListener)的问题,挺让人迷糊的. 他们都是加载Be ...

  4. Difference between applicationContext.xml and spring-servlet.xml in Spring Framework

    Question: Are applicationContext.xml and spring-servlet.xml related anyhow in Spring Framework? Will ...

  5. Spring的servlet context和application context

    Spring lets you define multiple contexts in a parent-child hierarchy. The applicationContext.xml def ...

  6. Spring------约束导入和application.xml的引入方式

    1.spring约束的导入 2.SSH常用约束 3.application.xml的引入方式 <1.通过ClassPathXmlApplicationContext引入配置文件applicati ...

  7. application/xml 和 text/xml的区别

    application/xml and text/xml的区别 经常看到有关xml时提到"application/xml" 和 "text/xml"两种类型, ...

  8. applicationContext.xml和dispatcher-servlet.xml的区别

    在SpringMVC项目中我们一般会引入applicationContext.xml和dispatcher-servlet.xml两个配置文件,这两个配置文件具体的区别是什么呢? Spring 官方文 ...

  9. spring-mvc.xml 和 application-context.xml的配置与深入理解

    在java框架这个话题,前几篇文章是基于搭建ssm项目框架,以及web.xml的配置讲解,本篇主要就ssm框架的其他配置文件进行深入讲解,他们分别是:1.application-context.xml ...

随机推荐

  1. sshuttle基于VPN的透明代理,安全连接

    sshuttle基于VPN的透明代理, 通过 ssh 创建一条从你电脑连接到任何远程服务器的 VPN 连 sudo sshuttle -r username@sshserver 0.0.0.0/0 - ...

  2. Android setTag IllegalArgumentException

    E/AndroidRuntime(19480): java.lang.IllegalArgumentException: The key must be an application-specific ...

  3. transition与visibility与display

    http://www.zhangxinxu.com/wordpress/2013/05/transition-visibility-show-hide/ 术语解释是: visibility: 离散步骤 ...

  4. HDOJ 1495 非常可乐 【BFS】

    非常可乐 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  5. XmlSerializer

    XmlSerializer作用是将对象序列化到 XML 文档中和从 XML 文档中反序列化对象.XmlSerializer 使您得以控制如何将对象编码到 XML 中. 所在的命名空间:System.X ...

  6. 异常IllegalStateException终于解决了

    还是由于一个类中使用xutils进行联网请求,开启了两个线程,导致在得到请求数据之前viewPagerAdapter就已经setAdapter了,setAdapter时getCount是0,但是数据加 ...

  7. Git--廖雪峰的博客的学习笔记

    为了督促自己能看完这个网站的学习教程,边看边做了些简要的笔记,记录了常用命令,其实也就是自己打了些简单的命令,好多直接就粘贴过来了,也算是一个学习的证明吧,想按详细的教程,还是要去博主的园子学习啊地址 ...

  8. NXT项目准备资料

    聊天资源 http://www.cocoachina.com/ios/20150205/11116.html https://developer.layer.com/docs/ios/quick-st ...

  9. Objective-C中的SEL (转载)

     SEL 在Objective-C中,SEL是选择器(selector)的一个类型.选择器就是指向方法的一个指针,读者可以简单理解为程序运行到这里就会执行指定的方法,可以这样定义一个选择器: SEL  ...

  10. 一篇入门的php Class 文章

    刚在大略浏览了一下首页更新的那篇有关Class的文章(指PHPE的那篇 http://www.phpe.net/articles/389.shtml ),很不错,建议看看.  对类的摸索--俺用了半年 ...