web.xml配置介绍
来源:互联网 发布:vb中inputbox什么意思 编辑:程序博客网 时间:2024/05/16 19:20
web.xml的作用
web.xml文件是用来初始化配置信息:比如Welcome页面、servlet、servlet-mapping、filter、listener、启动加载级别等。
当你的web工程没用到这些时,你可以不用web.xml文件来配置你的Application。
web.xml的关键元素分析
1、welcome-file-list 和 welcome-file元素
在访问一个网站时,用户看到的第一个页面就是欢迎页面。通常,欢迎页面都在web.xml中指定
<welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list>
2、filter和filter-mapping元素
filter元素用于声明一个过滤器,使用该元素可以同时拦截多个请求的URL。filter-mapping元素用来指定与过滤器关联的URL
<!--配置struts2的核心过滤器 --><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping>
3、error-page元素
配置error-page元素来捕获java异常,此时需要设置exception来指定java中的异常
<error-page><error-code>404</error-code><location>/error.jsp</location><!-- 如果发生http404错误,则返回location子元素指定的文件 --></error-page><!-- 用于捕获java异常 --><error-page><exception-type>java.lang.Exception</exception-type><location>/error.jsp</location></error-page>
4、listener元素
该元素用来注册监听器,并使子元素listener-class指定监听程序的完整限定类名
<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><context-param><param-name>contextConfigLocation</param-name><param-value>classpath:applicationContext.xml</param-value></context-param>
5、session-config元素
该元素用来指定会话过期时间
<session-config><session-timeout>30</session-timeout><!-- 单位是分 --></session-config>
6、init-param元素
该元素用来定义参数
0 0
- web.xml配置介绍
- web.xml 配置介绍
- web.xml 配置介绍
- web.xml 配置介绍
- web.xml配置详细介绍
- web.xml配置详细介绍
- java web.xml 节点配置介绍
- web.xml与注解配置servlet使用介绍
- Servlet介绍(三)——web.xml配置
- XML Web Service介绍
- web.xml元素介绍
- web.xml元素介绍
- web.xml元素介绍
- web.xml元素介绍
- web.xml元素介绍
- web.xml详细介绍
- web.xml元素介绍
- web.xml元素介绍
- typedef使用
- Lua中实现类的原理
- thinkpad远程桌面全屏与退出
- cstring 转 WCHAR*
- web项目中代码引用了本地包,又需要使用maven打war包时,pom的配置方法
- web.xml配置介绍
- 新手快速搭建openfire环境指南
- thinkphp关键字描红
- Android判断网络是否打开,并打开设置网络界面
- OpenCV-----分离颜色通道 & 多通道图像混合
- Fortran_PARAMETER
- 五分钟让你明白中国的内需是怎么回事
- Cocos2dx2.X 下获取当时间
- RAC 完整显示 crs_stat 命令中 name 列的脚本