项目中有web。xml时,则以项目中的为准,项目中无则以tomcat下的web,xml为准。
```css
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
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">
</web-app>
表示模板的引用,
<display-name>“项目名称”</display-name>
<description>项目的描述</description>
<icon>
<small-icon>‘大小图标路径’f</small-icon>
<large-icon>/images/large.gir</large-icon>
</icon
//servlet初始化标签
<context-param>
<param-name>‘初始化参数名字’</param-name>
<param-value>‘初始化参数值’</param-value>
</context-param>
此所设定的参数,在JSP网页中可以使用下列方法来取得:${initParam.param_name}
若在Servlet可以使用下列方法来获得:
String param_name=getServletContext().getInitParamter("param_name");
<filter>
<filter-name>‘过滤器名字’</filter-name>
<filter-class>‘过滤器类的地址’</filter-class>
‘初始化标签’
<init-param>
<param-name>encoding</param-name>
<param-value>GB2312</param-value>
</init-param>
</filter>
‘定义过滤器的作用点’
<filter-mapping>
<filter-name>‘用到的过滤器名字’</filter-name>
<url-pattern>‘在哪些url路径上作用过滤器’/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>定义session的失效时间单位分钟20</session-timeout>
</session-config>
‘服务启动后访问的首页地址,配置多个则按顺序查找知道找到为止’
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
‘定义出现错误的跳转页面,如页面出现404则调往404页面,项目抛出异常则调往exception页面’
<error-page>
<error-code>404</error-code>
<location>/error404.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/except.jsp</location>
</error-page>
‘引用资源标签’
<resource-ref>
<description>‘资源描述’JNDI JDBC DataSource of JSPBook</description>
<res-ref-name>‘资源名字’jdbc/sample_db</res-ref-name>
<res-type>‘资源类型’javax.sql.DataSoruce</res-type>
<res-auth>资源由Application或Container来许可Container</res-auth>
<res-sharing-scope>Shareable|Unshareable</res-sharing-scope> 资源是否可以共享.默认值为 Shareable
</resource-ref>