标签:
<web-app version="3.0" 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_3_0.xsd">
</web-app>
<icon>
<small-icon>/images/app_small.gif</small-icon>
<large-icon>/images/app_large.gif</large-icon>
</icon>
<display-name>Tomcat Example</display-name>
<disciption>Tomcat Example servlets and JSP pages.</disciption>
<context-param>
<param-name>ContextParameter</para-name>
<param-value>test</param-value>
<description>It is a test parameter.</description>
</context-param>
<filter>
<filter-name>setCharacterEncoding</filter-name>
<filter-class>com.myTest.setCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>setCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.listener.SessionListener</listener-class>
</listener>
<servlet> 用来声明一个servlet的数据,主要有以下子元素:
<servlet-name> 指定servlet的名称
<servlet-class> 指定servlet的类名称
<jsp-file> 指定web站台中的某个JSP网页的完整路径
<init-param> 用来定义参数,可有多个init-param。
<load-on-startup> 当值为正数或零时,从小到大加载。否则第一次访问时加载。
<servlet-mapping> 用来定义servlet所对应的URL,包含两个子元素
<servlet-name> 指定servlet的名称
<url-pattern> 指定servlet所对应的URL
<!-- 基本配置 -->
<servlet>
<servlet-name>snoop</servlet-name>
<servlet-class>SnoopServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>snoop</servlet-name>
<url-pattern>/snoop</url-pattern>
</servlet-mapping>
<!-- 高级配置 -->
<servlet>
<servlet-name>snoop</servlet-name>
<servlet-class>SnoopServlet</servlet-class>
<init-param>
<param-name>foo</param-name>
<param-value>bar</param-value>
</init-param>
<run-as>
<description>Security role for anonymous access</description>
<role-name>tomcat</role-name>
</run-as>
</servlet>
<servlet-mapping>
<servlet-name>snoop</servlet-name>
<url-pattern>/snoop</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>120</session-timeout><!-- 单位为分钟 -->
</session-config>
<mime-mapping>
<extension>htm</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- 1、通过错误码来配置error-page。当系统发生×××错误时,跳转到错误处理页面。 -->
<error-page>
<error-code>404</error-code>
<location>/NotFound.jsp</location>
</error-page>
<!-- 2、通过异常的类型配置error-page。(即空指针异常)时,跳转到错误处理页面。 -->
<error-page>
<exception-type>java.lang.NullException</exception-type>
<location>/error.jsp</location>
</error-page>
<jsp-config> 包括 <taglib>和<jsp-property-group>两个子元素。其中<taglib>元素在JSP1.2时就已经存在;而<jsp-property-group> 是JSP 2.0 新增的元素。
<jsp-property-group> 元素主要有八个子元素,它们分别为:
<description> 设定的说明
<display-name> 设定名称
<url-pattern> 设定值所影响的范围,如: /CH2 或 /*.jsp
<el-ignored> 若为 true,表示不支持 EL 语法
<scripting-invalid> 若为 true,表示不支持 <% scripting %>语法
<page-encoding> 设定 JSP 网页的编码
<include-prelude> 设置 JSP 网页的抬头,扩展名为 .jspf
<include-coda> 设置 JSP 网页的结尾,扩展名为 .jspf
<jsp-config>
<taglib>
<taglib-uri>Taglib</taglib-uri>
<taglib-location>/WEB-INF/tlds/MyTaglib.tld</taglib-location>
</taglib>
<jsp-property-group>
<description>Special property group for JSP Configuration JSP example.</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>/jsp/* </url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>GB2312</page-encoding>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/include/prelude.jspf</include-prelude>
<include-coda>/include/coda.jspf</include-coda>
</jsp-property-group>
</jsp-config>
标签:
原文地址:http://www.cnblogs.com/LiZhiW/p/4313844.html