Tomcat学习—Tomcat的web.xml配置文件

本文详细介绍了Tomcat配置文件web.xml的基本配置,包括默认文件设置、报错文件设置、会话超时设置及过滤器的配置。

今天开始学习Tomcat的配置文件,自己学习和上网查看整理web.xml 的笔记!

1:web.xml配置简介:
(1)、默认(欢迎)文件的设置
 在\conf\web.xml中,<welcome-file-list>与IIS中的默认文件意思相同。

<span style="font-size:18px;"><welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
</welcome-file-list></span>

(2)、报错文件的设置
<span style="font-size:18px;"><error-page>
 <error-code>404</error-code>
 <location>/notFileFound.jsp</location>
</error-page>
<error-page>
 <exception-type>java.lang.NullPointerException</exception-type>
 <location>/null.jsp</location>
</error-page></span>

如果某文件资源没有找到,服务器要报404错误,按上述配置则会调用\webapps\ROOT\notFileFound.jsp。
如果执行的某个JSP文件产生NullPointException ,则会调用\webapps\ROOT\null.jsp
 
(3)、会话超时的设置
设置session 的过期时间,单位是分钟;
<span style="font-size:18px;"><session-config>
 <session-timeout>30</session-timeout>
</session-config></span>
(4)、过滤器的设置
<span style="font-size:18px;"><filter>
filter-name>FilterSource</filter-name>
<filter-class>project4. FilterSource </filter-class>
</filter>
<filter-mapping>
<filter-name>FilterSource</filter-name>
<url-pattern>/WwwServlet</url-pattern>
(<url-pattern>/haha/*</url-pattern>)
</filter-mapping></span>

过滤:
1) 身份验证的过滤Authentication Filters
2) 日志和审核的过滤Logging and Auditing Filters
3) 图片转化的过滤Image conversion Filters
4) 数据压缩的过滤Data compression Filters
5) 加密过滤Encryption Filters
6) Tokenizing Filters
7) 资源访问事件触发的过滤Filters that trigger resource access events XSL/T 过滤XSL/T filters
8) 内容类型的过滤Mime-type chain Filter 注意监听器的顺序,如:先安全过滤,然后资源,
然后内容类型等,这个顺序可以自己定。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值