我的一个项目现在需要做静态化处理,准备使用tuckey的UrlRewriteFilter来做URL重写实现,servlet容器是tomcat6.0,基于ssh框架,项目名称叫做test。
web.xml的配置如下<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- 配置UrlRewrite --> <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>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!-- 配置Struts2 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,../config/struts2/struts-common.xml,
  ../config/struts2/struts-member1.xml,
  ../config/struts2/struts-member2.xml,
  ../config/struts2/struts-member3.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
urlrewrite.xml配置如下<urlrewrite>
   <rule>
  <from>^/test/index.html</from>
    <to type="forward">test/index.jsp</to>
   </rule>
</urlrewrite>
按照以上配置tomcat启动后,访问http://localhost:8080/test/或者http://localhost:8080/test/index.jsp都没有问题,能显示我需要的页面。此时urlrewrite已经配置了当请求test/index.html时,实际请求test/index.jsp。现在在地址栏输入http://localhost:8080/test/index.html时,没有转向index.jsp,显示错误404。
上面的配置有什么问题吗
还有一个问题,struts跳转我用的是动态方法调用即xxx!xxxx.action或者带参数的xxx!xxxx.action?flag='x',我想在浏览器中看到的效果是xxx_xxxx.xml?flag='x';urlrewrite.xml又应该怎么配置。
TomcatStrutsFilterHTML