`
qq769568569
  • 浏览: 832 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

web.xml中的contextConfigLocation的作用

阅读更多
在web.xml中通过contextConfigLocation配置spring,contextConfigLocation
 参数定义了要装入的 Spring 配置文件。

如果想装入多个配置文件,可以在 <param-value>
 标记中用逗号作分隔符。




在web.xml里配置Listener

xml 代码如下: 
  < listener >  
       <    listener-class > org.springframework.web.context.ContextLoaderListener listener-class >  
  <   /  listener >   

如果在web.xml里给该Listener指定要加载的xml,如:

xml代码如下:

<!-- spring config -->

      <context-param>

           <param-name>contextConfigLocation</param-name>  

           <param-value>classpath:applicationContext.xml</param-value>

      </context-param>

则会去加载相应的xml,而不会去加载/WEB-INF/下的applicationContext.xml。

但是,如果没有指定的话,默认会去/WEB-INF/下加载applicationContext.xml。

<!-- Baidu Button BEGIN -->
分享到:
评论

相关推荐

    spring在web.xml中和在struts中的不同配置..pdf

    在本文中,我们将探讨Spring在`web.xml`中的配置与在Struts中的配置差异,以及这两种配置方式背后的基本原理。 首先,Spring的核心是ApplicationContext,它是一个管理Bean的容器,可以看作是应用程序的上下文环境...

    加载spring 文件,在web.xml中的配置

    在Spring框架中,Web应用程序的配置通常涉及到对`web.xml`文件的设置,这是传统的部署描述符,用于定义Servlet、监听器和其他Web组件。当我们谈论“加载Spring文件,在web.xml中的配置”时,主要是指如何在Web应用...

    web.xml文件中配置(servlet, spring, filter, listenr)的加载顺序

    ### web.xml文件中配置(servlet, spring, filter, listener)的加载顺序 在Java Web应用开发中,`web.xml`文件是整个Web应用程序的核心配置文件之一,它定义了Servlet容器如何启动、初始化以及配置各个组件如...

    SSH和SSI等框架常用基础配置web.xml

    本文将详细介绍`web.xml`中的关键配置项,并解释其作用。 #### 一、`web.xml`文件结构 `web.xml`文件通常包含以下几个主要元素: 1. **`web-app`标签**:这是`web.xml`的根元素。 2. **`display-name`标签**:...

    web.xml中的listen

    ### Web.xml中的Listen知识点详解 #### 一、加载Spring配置文件 在Web应用程序开发中,特别是在使用Spring框架的情况下,配置文件的加载是非常重要的一个环节。`web.xml`是Servlet容器用来初始化Web应用的一个核心...

    web.xml中如何设置配置文件的加载路径实例详解

    web.xml中如何设置配置文件的加载路径实例详解 web应用程序通过Tomcat等容器启动时,会首先加载web.xml文件,通常我们工程中的各种配置文件,如日志、数据库、spring的文件等都在此时被加载,下面是两种常用的配置...

    开发web_xml.rar_WEB XML_java web开发_web.xml_web开发_web

    在Java Web开发中,`web.xml`文件是部署描述符(Deployment Descriptor)的核心部分,它在应用程序中扮演着至关重要的角色。`web.xml`文件是一个XML格式的配置文件,用于定义Servlet、过滤器(Filter)、监听器...

    web.xml配置解析[总结].pdf

    通过在`web.xml`中配置如下: ```xml &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener ``` 当Servlet容器启动时,`ContextLoaderListener`会查找`ApplicationContext`的配置...

    spring在web.xml中和在struts中的不同配置.[收集].pdf

    本篇文章将深入探讨Spring在`web.xml`中与在Struts中的不同配置方式,以及这两种方式背后的设计思想。 首先,ApplicationContext是Spring的核心组件,它是一个容器,负责管理和装配应用程序中的Bean。在Web应用中,...

    springmvc、spring、mybatis的resources配置文件和web.xml

    在Java Web开发中,Spring MVC、Spring和MyBatis是三个非常重要的框架,它们共同构建了一个灵活、高效的应用架构。这些框架的配置文件对于整个应用的运行至关重要,下面将详细讲解它们各自的资源配置以及与`web.xml`...

    web.xml配置解析.pdf

    当web.xml中配置了`&lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;`,容器启动时会调用其相关方法,初始化Spring应用上下文。ContextLoaderListener依赖于ContextLoader...

    JAVA web.xml配置详解

    --small-icon元素应指向web站台中某个小图标的路径,大小为16 X 16 pixel,但是图象文件必须为GIF或JPEG格式,扩展名必须为:.gif或.jpg. --&gt; 路径/small.gif &lt;!--large-icon元素应指向web站台中某个大图表路径,大小...

    Spring在web.xml中的配置详细介绍

    在Java Web应用中,Spring框架的使用已经非常普遍,而web.xml是Java EE标准的web应用配置文件,它用于配置web应用的各种属性。要将Spring框架与web.xml结合使用,需要进行一些特定的配置,从而使得Spring能够管理web...

    ssm框架下web项目,web.xml配置文件的作用(详解)

    ssm框架下web项目,web.xml配置文件的作用详解 SSM框架是Spring、Struts2和MyBatis三个框架的整合,它们之间的协作关系是:Struts2负责处理客户端的请求,Spring提供业务逻辑层的支持,MyBatis负责数据库的访问。在...

    web.xml配置[归纳].pdf

    在Java Web开发中,`web.xml`是应用的部署描述符,它是应用程序配置的核心,用于定义各种组件、过滤器、监听器等。以下是一些关键配置点的归纳: 1. **Spring上下文配置** 当我们需要改变`applicationContext.xml`...

    ssh框架在application.xml中配置数据源所需jar

    - dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation"). --&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...

    spring web.xml指定配置文件过程解析

    contextConfigLocation 是web.xml文件中的一个重要配置项,它负责指定上下文配置文件的路径。例如,在web.xml文件中,我们可以配置如下代码: ```xml &lt;param-name&gt;contextConfigLocation &lt;param-value&gt;classpath:...

    spring在web.xml中和在struts中的不同配置

    Spring 在 web.xml 中和在 Struts 中的不同配置 在本文中,我们将探讨 Spring 在 web.xml 中和在 Struts 中的不同配置。首先,我们需要了解 Spring 的核心概念之一:ApplicationContext。 ApplicationContext 是 ...

    Spring的监听器ContextLoaderListener的作用

    在 SSH 项目中,我们可以在 web.xml 文件中添加一段配置:&lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;classpath*:applicationContext-*.xml&lt;/param-value&gt; &lt;/context-param&gt; ...

Global site tag (gtag.js) - Google Analytics