今天我想在我的项目中使用urlrewrite技术,按照如下要求配置
(1)urlrewrite-3.2.0.jar到lib目录小
(2)拷贝urlrewrite3.2.dtd文件到WEB-INF目录下
(3)在WEB-INF目录下建立urlrewrite.xml
(4)web.xml
<!-- urlRewrite配置 -->
<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>error</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
(5)urlrewrite.xml
<rule>
<from>^/admin/login/success/main.html$</from>
<to type="forward">{contextPath}/adminLogin.action</to>
</rule>
最后不跳转,报404错误,网上查阅,web.xml中的urlrewrite要在strut2之前配置。改动之后还是不行。
最终结论
修改struts2的filter-mapping,配置改为
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
然后ok了