常用的设定,详细请看:
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
XML声明,定义XML的版本、编码格式。还有最重要的schema的来源
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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" version="2.4">
.......
</web-app>
<description>
当servlet的URL定义为其他文件类型的扩展名,该文件类型将不能访问,而访问了servlet
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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" version="2.4">
<display-name>myweb</display-name><!--站点名称-->
<description>这里是站点描述</description>
<icon>
<small-icon>/images/small.gif</small-icon><!--小图标的路径16*16,必须为gif jpge格式-->
<large-icon>/images/large.gif</large-icon><!--大图标的路径32*32,必须为gif jpge格式-->
</icon>
<!--如果存在<distributable/>则代表该站点能在多个JSP Container之间分散执行(分布式)-->
<distributable/>
<context-param><!--环境参数,设置常量,取得常量 this.getInitParameter("context");-->
<param-name>context</param-name>
<param-value>10000</param-value>
</context-param>
<filter><!--声明filter-->
<filter-name>filterName</filter-name>
<filter-class>filter.filterName</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping><!--定义filter所对应的URL-->
<filter-name>filterName</filter-name>
<url-pattern>/filterName</url-pattern>
<dispatcher>REQUEST|INCLUDE|FORWARD|ERROR</dispatcher><!--filter对应的请求方式,有4种方式,默认REQUEST-->
</filter-mapping>
<listener><!--设定Listener接口-->
<listener-class>listener.ListenerClassName</listener-class>
</listener>
<servlet><!--声明servlet的数据-->
<servlet-name>servletName</servlet-name>
<servlet-class>servlet.servletName</servlet-class>
<init-param><!--初始化参数,可以在init()中使用ServletConfig().getInitParamenter("name")取得-->
<param-name>name</param-name>
<param-value>123</param-value>
</init-param>
<load-on-startup>n</load-on-startup><!--站点启动时,此servlet会被自动加载执行,1表示最早,2,3...-->
</servlet>
<servlet-mapping><!--定义servlet所对应的URL-->
<servlet-name>name</servlet-name>
<url-pattern>/name</url-pattern>
</servlet-mapping>
<session-config><!--设置session超时时间(20分钟)默认按服务器配置-->
<session-timeout>20</session-timeout>
</session-config>
<mime-mapping><!--定义某个扩展名和某个MIME Type做映射-->
<extension>doc</extension>
<mime-type>application/vnd.ms-word</mime-type>
</mime-mapping>
<welcome-file-list><!--设置首页列表-->
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page><!--将错误代码对应到WEB站点的资源路径-->
<error-code>错误代码</error-code>Exception
<location>/路径/</location>
</error-page>
<error-page><!--将异常的种类对应到WEB站点的资源路径-->
<exception-type>Exception</exception-type>
<location>/路径/</location>
</error-page>
<jsp-config><!--JSP的相关配置-->
<taglib><!--JSP所用到的Tag Library-->
<taglib-uri>URI</taglib-uri>
<taglib-location>/WEB-INF/lib/xxx.tld</taglib-location>
</taglib>
<jsp-property-group>
<description>此设定的说明</description>
<display-name>Name</display-name>
<url-pattern>URL</url-pattern><!--此设定影响的范围-->
<el-ignored>true|false</el-ignored><!--true表示不支持EL语法-->
<scripting-invalid>encoding</scripting-invalid><!--jsp的编码-->
<include-coda>...jspf</include-coda><!--JSP的结尾,扩展名.jspf-->
</jsp-property-group>
</jsp-config>
<resource-ref><!--利用JNDI取得站点可利用的资源-->
<description>资源说明</description>
<res-ref-name>资源名称</res-ref-name>
<res-type>资源种类</res-type>
<res-auth>Application|Container</res-auth><!--资源经由什么许可-->
<res-sharing-scope>Shareable|Unshareable</res-sharing-scope><!--资源是否可以共享,默认为Shareable-->
</resource-ref>
</web-app>