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">
<!-- 对这个WEB应用进行描述 -->
<description>Test</description>
<!-- 显示 -->
<display-name>Test</display-name>
<!-- 定仪全局变量 -->
<context-param>
<!-- 描述符 -->
<description>context param</description>
<!-- 参数 -->
<param-name>encoding</param-name>
<!-- 参数直 -->
<param-value>UTF-8</param-value>
</context-param>

<!-- 定义网站的字符编码方式 -->
<locale-encoding-mapping-list>
<locale-encoding-mapping>
<locale>zh</locale>
<encoding>gb2312</encoding>
</locale-encoding-mapping>
</locale-encoding-mapping-list>

<!-- 定仪过滤器 -->
<filter>
<filter-name>testFilter</filter-name>
<filter-class>com.jonw.filter.TestFilter</filter-class>
<!-- 局部变量,只适用此Filter -->
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>testFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 定仪一个监听器 -->
<listener>
<listener-class>com.jonw.listener.TestListener</listener-class>
</listener>
<!-- 定仪一个验证用户登录的Servlet -->
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>com.jonw.servlet.UserLogin</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern>/login.do</url-pattern>
</servlet-mapping>
<!-- WEB应用的默认主页 -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- 声明数据源,此数据源放在META-INF文件夹下 -->
<resource-ref>
<description>DataSource</description>
<res-ref-name>Jdbc/Connection</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!-- 定仪Session的超时时间,在这理定仪一分钟 -->
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<!-- 设置JSP的各属性 -->
<jsp-config>
<jsp-property-group>
<!-- 应用范围 -->
<url-pattern>/*</url-pattern>
<!-- 是否支持EL表达式 -->
<el-ignored>false</el-ignored>
<!-- 是否技技页面JAVA代码 -->
<scripting-invalid>false</scripting-invalid>
</jsp-property-group>
</jsp-config>
<!-- 定仪页面没找到时,由容器指向哪个页面 -->
<error-page>
<error-code>404</error-code>
<location>/without.jsp</location>
</error-page>
<!-- 定仪整个WEB应用出现空指向异常所指向哪个页面-->
<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>/null.jsp</location>
</error-page>
<!-- 设置整个WEB站点的图标,即浏懒器URL左边的图标 -->
<icon>
<!-- 大图标 -->
<small-icon>/images/small.jpg</small-icon>
<!-- 小图标 -->
<large-icon>/images/large.jpg</large-icon>
</icon>
<!-- 避免浏懒器打开以下格式的文件。 -->
<mime-mapping>
<extension>xls</extension>
<mime-type>application/msexcel</mime-type>
</mime-mapping>
<mime-mapping>
<extension>doc</extension>
<mime-type>application/msword</mime-type>
</mime-mapping>
<!-- WEB应用安全的配置 -->
<security-constraint>
<!-- 显示 -->
<display-name>security realm</display-name>
<!-- 安全方式 -->
<web-resource-collection>
<!-- 可以吓写,不用管 -->
<web-resource-name>all role access</web-resource-name>
<!-- 应用WEB应用的所有文件 -->
<url-pattern>/*</url-pattern>
<!-- 定仪有哪几种访问方式 -->
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>DELETE</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<!-- 定仪哪些用户有访问权限 -->
<auth-constraint>
<role-name>wang</role-name>
<role-name>admin</role-name>
</auth-constraint>
<!-- 用户数据约述 -->
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<!-- 声明有多少个用户,当然此用户必须在/conf/tomcat-user.xmL文件中存在, -->
<security-role>
<description>role</description>
<role-name>wang</role-name>
</security-role>
<!-- 声明有多少个用户,当然此用户必须在/conf/tomcat-user.xmL文件中存在, -->
<security-role>
<description>role</description>
<role-name>admin</role-name>
</security-role>
<!-- 声明有多少个用户,当然此用户必须在/conf/tomcat-user.xmL文件中存在, -->
<security-role>
<description>role</description>
<role-name>manager</role-name>
</security-role>
<!-- 用户登录 -->
<login-config>
<!-- 用户登录方式 -->
<auth-method>FORM</auth-method>
<!-- 登录界面,这个与登录方式有关联 -->
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/login-Error.jsp</form-error-page>
</form-login-config>
</login-config>
</web-app>

transport-guarantee元素必须具有如下的某个值:

● NONE,这意味着应用不需要传输保证。

● INTEGRAL,意味着服务器和客户端之间的数据必须以某种方式发送,而且在传送中不能改变。

● CONFIDENTIAL,这意味着传输的数据必须是加密的数据。

<auth-method>元素有如下几值可选:

NONE

FORM 基于FROM表单的验证

DIGEST 基于digest的验证

BASIC 基于BASIC的验证

CLIENT-CERT 基于客户端证书的验证,此验证会跳转到SSL的协议上
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值