<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://xmlns.jcp.org/xml/ns/javaee"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"version="4.0"><filter><filter-name>struts2</filter-name><!--Struts2的控制器--><filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping></web-app>
filter 的 url-pattern 说明:
/*
表示匹配所有资源请求路径,即表示所有的请求都会经过该过滤器处理,如下的请求地址:
http://localhost:8080/sd/nameform.jsp
资源的请求路径 /nameform.jsp
与 /*
匹配,所以上述的请求会先经由控制器 StrutsPrepareAndExecuteFilter
处理。