web.xml常用标签(随时补充)

web.xml配置(常用标签)

<?xml version="1.0" encoding ="ISO-8859-1"?> ->common
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   version="2.5"> ->common
//other tag
</web-app>

other tag |

basic tag |<display-name>,<description>,<icon>(<small-icon>|<large-icon>)
example:
<display-name>Develop Example</display-name>
<description>JSP 2.0 Tech Book's Examples</description>
<icon>
   <small-icon>/images/small.gif</small-icon>
   <large-icon>/images/large.gir</large-icon>
</icon>

<distributable/> 站点是否开放分布式处理,该标签为空标签。

<context-param> web站点环境参数
  <param-name>param_name</param-name>
  <param-value>param_value</param-value>
</context-param>
获取方法 JSP $(initParam.param_name)
         Servlet String param_name = getServletContext().getInitParameter("param_name");

<filter> 过滤器
  <filter-name>filter_name</filter-name>
  <filter-class>FilterClass</filter-class>
  <init-param>
    <param-name>param_name</param-name>
<param-value>param_value</param-value>
  </init-param>
</filter>

<filter-mapping>
<filter-name>filter_name</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<listener> 监听器
     <display-name>listener_name</display-name>
     <listener-class>ListenerClass</listener-class>
</listener>

<servlet>
<servlet-name>servlet_name</servlet-name>
<servlet-class>ServletClass</servlet-class>
<init-param>
<param-name></param-name>
<param-value></param-value>
</init-param>
<load-on-startup>2</load-on-startup>指定当web应用启动时,装载servlet的次序。当值为0或正数时,servlet容器先加载小的;如果值为负数或者没有设定,那么servlet容器将在web客户首次访问这个servlet时加载它。
</servlet>

<servlet-mapping>
<servlet-name></servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>

<session-config> 设定web站点httpSession的生命周期(单位:分钟)
<session-timeout>5</session-timeout>
</session-config>

你可能感兴趣的:(Web)