I used urlrewriter, but found some problems, the configuration is as follows:
The 2.4 version of the servlet specification adds a new <dispatcher> element to the deployment descriptor. This element has four possible values: REQUEST, FORWARD, INCLUDE and ERROR. Any number can be added to a <filter-mapping> element The <dispatcher> makes the filter act on requests directly from the client, requests from forward, requests from include, and requests from <error-page>. If no <dispatcher> element is specified, the default value is REQUEST.
The following examples illustrate its usage:
Example 1:
In this case, the filter will be applied to requests that start with /person/... sent directly from the client. Because there is no <dispatcher> element specified here, the default value is REQUEST.
Example 2:
Intercepting a request for transmitting over ProductServlet to request dispatcher include a method of
Example 3:
In this case, if the request starts with /person/... and is passed through the forward method of the request dispatcher or directly from the client, it must pass through this filter.
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < filter > <filter-name>UrlRewriteFilter</filter-name><filter-class> org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class><init-param><param-name>logLevel</param-name><param-value>TRACE</param-value></
init-param >
</ filter >
< filter-mapping >
< filter-name > UrlRewriteFilter </ filter-name >
< url-pattern > *.do </ url-pattern >
</ filter-mapping >
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < filter > <filter-name>UrlRewriteFilter</filter-name><filter-class> org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class><init-param><param-name>logLevel</param-name><param-value>TRACE</param-value></
init-param >
</ filter >
< filter-mapping >
< filter-name > UrlRewriteFilter </ filter-name >
< url-pattern > *.do </ url-pattern >
</ filter-mapping >
The 2.4 version of the servlet specification adds a new <dispatcher> element to the deployment descriptor. This element has four possible values: REQUEST, FORWARD, INCLUDE and ERROR. Any number can be added to a <filter-mapping> element The <dispatcher> makes the filter act on requests directly from the client, requests from forward, requests from include, and requests from <error-page>. If no <dispatcher> element is specified, the default value is REQUEST.
The following examples illustrate its usage:
Example 1:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < filter-mapping > //Filter mapping
< filter-name > Logging Filter </ filter-name > //The name of the filter
< url-pattern > /person/* </ url-pattern > // Intercept the url starting with person
</ filter-mapping >
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < filter-mapping > //Filter mapping
< filter-name > Logging Filter </ filter-name > //The name of the filter
< url-pattern > /person/* </ url-pattern > // Intercept the url starting with person
</ filter-mapping >
In this case, the filter will be applied to requests that start with /person/... sent directly from the client. Because there is no <dispatcher> element specified here, the default value is REQUEST.
Example 2:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < filter-mapping >
< filter-name > Logging Filter </ filter-name > //过滤器的名字
< servlet-name > LogServlet </ servlet-name > //截获名字为LogServlet的servletl
< dispatcher > INCLUDE </ dispatcher >
</filter-mapping>
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < filter-mapping >
< filter-name > Logging Filter </ filter-name > //过滤器的名字
< servlet-name > LogServlet </ servlet-name > //截获名字为LogServlet的servletl
< dispatcher > INCLUDE </ dispatcher >
</filter-mapping>
Intercepting a request for transmitting over ProductServlet to request dispatcher include a method of
Example 3:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < filter-mapping >
< filter-name > Logging Filter </ filter-name >
< url-pattern > /person/* </ url-pattern >
< dispatcher > FORWARD </ dispatcher >
< dispatcher > REQUEST </ dispatcher >
</ filter-mapping >
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> < filter-mapping >
< filter-name > Logging Filter </ filter-name >
< url-pattern > /person/* </ url-pattern >
< dispatcher > FORWARD </ dispatcher >
< dispatcher > REQUEST </ dispatcher >
</ filter-mapping >
In this case, if the request starts with /person/... and is passed through the forward method of the request dispatcher or directly from the client, it must pass through this filter.