<context-param>的contextConfigLocation以及DispatcherServlet的contextConfigLocation
来源:互联网 发布:怎么注册域名 编辑:程序博客网 时间:2024/06/05 19:40
<pre name="code" class="html"><?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name></display-name> <!-- context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/applicationContext.xml,/WEB-INF/classes/module/*Context.xml </param-value> </context-param --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/servlet-context.xml,/WEB-INF/classes/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- springmvc 请求配置文件 --><servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/servlet-context.xml,/WEB-INF/classes/applicationContext.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
-----------------------------------------------------------------------
在web.xml中通过contextConfigLocation配置spring,<span style="font-family: 新宋体;">contextConfigLocation</span> 参数定义了要装入的 Spring 配置文件。如果想装入多个配置文件,可以在 <code><param-value></code> 标记中用逗号作分隔符。---------------------------------------------------------------
在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。
0 0
- <context-param>的contextConfigLocation以及DispatcherServlet的contextConfigLocation
- Spring框架中context-param与servlet中init-param的contextConfigLocation的区别
- Spring框架中context-param与servlet中init-param的contextConfigLocation的区别
- Spring框架中context-param与servlet中init-param的contextConfigLocation的区别
- ContextLoaderListener contextConfigLocation DispatcherServlet 关系
- Spring MVC DispatcherServlet contextConfigLocation设置
- web.xml中的contextConfigLocation的作用
- spring中contextConfigLocation的配置作用
- 通过contextConfigLocation配spring的方式
- web.xml中contextConfigLocation的作用
- web.xml中的contextConfigLocation的作用
- web.xml中的contextConfigLocation的作用
- web.xml中contextConfigLocation参数的作用
- web.xml中的contextConfigLocation的作用
- web.xml中contextConfigLocation的配置方法
- web.xml中的contextConfigLocation的作用
- web.xml中的contextConfigLocation的作用
- web.xml中contextConfigLocation的作用
- iOS中,文件相对路径、绝对路径切换
- 开源许可,产品或社区?
- Java实现《简单自动关机助手》
- 黑马程序员——学习笔记——知识复习3
- php 代码优化建议
- <context-param>的contextConfigLocation以及DispatcherServlet的contextConfigLocation
- hdoj 开门人和关门人
- Sql Server 表中看不见的乱码
- 大连网站制作哪家好?
- C#返回上一页
- 类目和发布人不显示的问题 dede5.6升级到5.7sp1后
- oracle 11g-sqlplus登录密码问题
- 本地APT源服务器
- 完全图解SQL 2008数据库复制