转自:http://vti-iteye.iteye.com/blog/1699845
- <filter>
- <filter-name>UrlRewriteFilter</filter-name>
- <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>UrlRewriteFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>
- org.apache.struts2.dispatcher.FilterDispatcher
- </filter-class>
- </filter>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>/*</url-pattern>
- <dispatcher>REQUEST</dispatcher>
- <dispatcher>FORWARD</dispatcher>
- </filter-mapping>
//这里切记 拦截器一定要放在struts 的前面!
urlRewriter.xml
- <rule>
- <from>news-([0-9]+).html</from>
- <to type="forward">/ReadNews?id=$1</to>
- </rule>
//这里的意思是访问 news-1.html 就会跳转访问 ReadNews这个action,并且参数为1
$1对应的就是([0-9]+)