web.xml配置
<?xml version="1.0"
encoding="UTF-8"?>
<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">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!--配置过滤器www为包名+MyFilter为类名-->
<filter>
<filter-name>MyFilter</filter-name>
<filter-class>www.MyFilter</filter-class>
</filter>
<!--映射过滤器-->
<filter-mapping>
<filter-name>MyFilter</filter-name>
<!--“/*”表示拦截所有的请求 -->
<url-pattern>/*</url-pattern>