1.更改web.xml,,,在struts2拦截器前面添加urlrewrite配置信息,,默认是forward的
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<!-- 设备文件重加载间隔 (0默示随时加载, -1默示不重加载, 默认-1) -->
<init-param>
<param-name>logLevel</param-name>
<param-value>WARN</param-value>
</init-param>
<!-- 自定义配置文件的路径,是相对context的路径,(默认位置 /WEB-INF/urlrewrite.xml) -->
<init-param>
<param-name>confPath</param-name>
<param-value>/WEB-INF/urlrewrite.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
2.看一下struts2的dispatcher是什么,没有的话需要加上一个forward方式,不然没法拦截此请求
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<!-- 因为UrlReWrite默认转发方式为FORWARD,所以要想让你的Struts2过滤器拦截到UrlReWrite转发的请求,必须在filter-mapping加上<dispatcher>FORWARD</dispatcher> -->
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
3.配置urlrewrite.xml
<rule>
<note>登录Demo</note>
<from>/login.html</from>
<to>/membersLogin/membersLoginAction!membersLogin.action</to>
</rule>
通过以上几乎就ok了,若还不成功欢迎交流,QQ群4060038