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. qtcreator增加doxygen注释

    1,在以下网址找到和你的qt creator版本相对应的插件文件,还要注意系统版本 http://dev.kofee.org/projects/qtcreator-doxygen/files 2,根据 ...

  2. DbConnectionFactory 数据库连接

    /** * */package com.sprucetec.dbatch.tmsfee;import java.io.Serializable;import java.sql.Connection;i ...

  3. CSharp tar类型文件压缩与解压

    最近闲暇时间开始写点通用基础类在写到tar类型文件压缩与解压时遇到点问题 压缩用的类库我是下载的 SharpZipLib_0860版本 先上代码 加压核心 /// <summary> // ...

  4. [Leetcode][Python]23: Merge k Sorted Lists

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 23: Merge k Sorted Listshttps://oj.leet ...

  5. Xcode5新特性

    小引: 自从北京时间2013年06月11日苹果发布Xcode 5 Developer Preview 1,到现在,苹果也放出了Xcode 5 Developer Preview 3,速度还是蛮快的,希 ...

  6. dataset 用法(2)

    1.为DataTable添加列 (1)添加列 DataTable  tbl = ds.Tables.Add("User"); DataColumn col =tbl.Columns ...

  7. Lambda表达式图解

    internal delegate int MyDel(int x); public class Lambda { ; };//匿名方法 ; };//Lambda表达式 ; };//Lambda表达式 ...

  8. 开发移动端web的一些知识

    由于智能机的普及,越来越多网页支持移动端了,那么如何解决适配移动端呢 在这总结一下自己的学习笔记 viewport:虚拟的容器,仅在移动设备有效 <meta name="viewpor ...

  9. SQL学习之使用视图

    1.简介:视图是虚拟的表.与包含的数据不一样,视图只包含使用时动态检索数据的查询.重点:视图是一个查询,不是一个表!

  10. onhashchange事件--司徒正美

    onhashchange事件是针对AJAX无缝刷新导致后退键失效而产生的事件,因此属于一个够新的事件,浏览器兼容性如下: Feature Chrome Firefox IE Opera Safari ...