先加载一段写好的web.xml:

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app>
<display-name>Archetype Created Web Application</display-name> <!--Spring ApplicationContext 载入 -->
<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/dispatcher-servlet.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> <!-- session超时定义,单位为分钟 -->
<session-config>
<session-timeout>30</session-timeout>
</session-config> <!-- 默认首页定义 -->
<welcome-file-list>
<welcome-file>index.ftl</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

web.xml中通过以下配置加载/WEB-INFO/applicationContext.xml(spring 全局配置文件,用来控制spring特性)

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

/WEB-INFO/applicationContext.xml是默认路径及文件名称,如果调整文件路径或名称,需要额外添加以下contextConfigLocation参数:

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-new.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

web.xml中通过以下配置加载/WEB-INFO/dispatcher-servlet.xml(属于spring mvc,加载控制器,拦截uri转发view)

    <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/dispatcher-servlet.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>

web.xml基本配置描述的更多相关文章

  1. web.xml 文件配置01

    web.xml 文件配置01   前言:一般的web工程中都会用到web.xml,方便开发web工程.web.xml主要用来配置Filter.Listener.Servlet等.但是要说明的是web. ...

  2. SSH web.xml文件配置

    启动一个WEB项目的时候, WEB容器会去读取它的配置文件web.xml web.xml中配置的加载优先级:context-param -> listener -> filter -> ...

  3. web.xml filter配置

    filter介绍: filter主要用于对用户请求request进行预处理,和对Response进行后处理,是个典型的处理链. 详细解析起来就是:Filter对用户请求进行预处理,接着将请求HttpS ...

  4. JavaWeb工程中web.xml基本配置

    一.理论准备 先说下我记得xml规则,必须有且只有一个根节点,大小写敏感,标签不嵌套,必须配对. web.xml是不是必须的呢?不是的,只要你不用到里面的配置信息就好了,不过在大型web工程下使用该文 ...

  5. spring web.xml 难点配置总结

    web.xml web.xml是所有web项目的根源,没有它,任何web项目都启动不了,所以有必要了解相关的配置. ContextLoderListener,ContextLoaderServlet, ...

  6. 在web.xml中配置error-page

    在web.xml中配置error-page 在web.xml中有两种配置error-page的方法,一是通过错误码来配置,而是通过异常的类型来配置,分别举例如下: 一.   通过错误码来配置error ...

  7. Struts2 web.xml文件配置

    在导入了项目需要使用的核心jar包之后需要在web.xml中配置Struts. 1. Struts2的知识点普及: Struts2共有5类配置文件,分别罗列如下: 1), Web.xml; 在没有使用 ...

  8. struts2在web.xml中配置详情

    web.xml是web应用中载入有关servlet信息的重要配置文件,起着初始化servlet,filter等web程序的作用. 通常,全部的MVC框架都须要Web应用载入一个核心控制器.那採取什么方 ...

  9. web.xml中配置log4j

    1.将 commons-logging.jar和 log4j.jar加入你的项目中:2.在src/下创建log4j.properties|log4j.xml文件:3.在web.xml中配置log4j的 ...

随机推荐

  1. Python:函数定义

    #!/usr/bin/python3 #函数 def add(a,b): return a+b print("add(2,5) = ",add(2,5)) def add2(a,b ...

  2. 如何去掉textarea右下角的灰色角标?

    在css中定义: resize: none; ,这个样式同时禁用textarea调整大小

  3. dedecms修改templets为别的名字

    修改templets模板文件夹的方法: 首先找到系统配置文件common.inc.php,此文件存放在Include目录下,打开common.inc.php来修改默认模板目录templets, 查找: ...

  4. eval函数:分号的应用

    eval("echo'hello world';"); ("参数;") eval函数把参数当做php代码来执行,参数后要有分号,最后还要另加一个分号 相当于: ...

  5. MBR

    Mbr位于磁盘的0柱面,0磁头,1扇区. MBR       有三部分构成,主引导程序,硬盘分区表DPT和,硬盘的有效标志55AA.在512个字节的主引导扇区里. 主引导程序占446个字节,dpt占6 ...

  6. C++类型转换运算符

    C++中提供4中类型转运算符,分别是:static_cast.dynamic_cast.reinterpret_cast和const_cast; 语法格式如下: 类型转换运算符 < type_i ...

  7. SOC

    http://marsvaadin.iteye.com/blog/1311438 http://blog.csdn.net/cxxsoft/article/details/12610641

  8. 2015 CCC - 01 统计数对

    源:CNUOJ-0384 http://oj.cnuschool.org.cn/oj/home/problem.htm?problemID=354 题目分析:当时拿到这道题第一个想法就是排序后n^2暴 ...

  9. -_-#【工具】图片导出PDF

  10. 部署lvs-rrd监控LVS

    1.安装rrdtool .tar.gz cd rrdtool- ./configure -prefix=/usr/local/rrdtool make make instal 安装完毕后将rrdtoo ...