web.xml 常用配置

 常用的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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值