常用的web.xml的配置说明
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list> --欢迎页,即默认页的文件列表
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param> --项目级的初始参数,通过application即ServletContext的getInitParameter()方法获取
<param-name>test</param-name>
<param-value>testtest</param-value>
</context-param>
<error-page> --默认的错误页
<error-code>404</error-code> --条件为错误号404时(文件名出错)
<location>/index.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.NullPointerException</exception-type> --异常类型,指定的异常类
<location>/err.jsp</location>
</error-page>
<listener> -- 临听器类
<listener-class>
web.function.SessionCounter
</listener-class>
</listener>
<servlet> -- Servlet的初始化
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>MyServlet</servlet-name>
<servlet-class>servlet.demo.MyServlet</servlet-class>
<init-param>
<param-name>myarg</param-name>
<param-value>1</param-value>
</init-param>
</servlet>
<servlet-mapping> -- Servlet的映射
<servlet-name>MyServlet</servlet-name>
<url-pattern>/servlet/MyServlet</url-pattern>
</servlet-mapping>
<icon> -- 站点图标
<large-icon></large-icon>
<small-icon></small-icon>
</icon>
<filter> -- 站点过滤器
<filter-name>myfilter</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter-mapping>-- 过滤器的映射
<filter-name>myfilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config> -- 会话的设置
<session-timeout>10</session-timeout>
</session-config>
</web-app>
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/fzmatthew/archive/2008/09/18/2943400.aspx