当前位置: 代码迷 >> J2EE >> urlrewriter 和 Struts2 整合 访问.html 不是访问对应的action帮忙看看是哪里配置异常
  详细解决方案

urlrewriter 和 Struts2 整合 访问.html 不是访问对应的action帮忙看看是哪里配置异常

热度:726   发布时间:2016-04-22 02:57:48.0
urlrewriter 和 Struts2 整合 访问.html 不是访问对应的action帮忙看看是哪里配置错误
用的jar包:urlrewrite-3.1.0.jar


web.xml配置过滤器:
 <!-- Character Encoding filter -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>

  <filter-mapping>
  <filter-name>encodingFilter</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
   
<!-- Config UrlRewriteFilter -->
<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>WARN</param-value>
  </init-param>
  </filter>
  <filter-mapping>
  <filter-name>UrlRewriteFilter</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
 
<!-- 配置struts2的过滤器 -->
<filter>
<filter-name>struts</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter>
  <filter-name>ActionContextCleanUp</filter-name>
  <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
  </filter>
  <filter-mapping>
<filter-name>ActionContextCleanUp</filter-name>
<url-pattern>*.do</url-pattern>

</filter-mapping>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>*.do</url-pattern>
<dispatcher>REQUEST</dispatcher> 
  <dispatcher>FORWARD</dispatcher> 
</filter-mapping>

<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>

urlrewrite.xml 配置文件:
<rule>
  <from>/test.html</from>
  <to>test.do</to>
  </rule>

http://localhost:8080/work/test.html 没有进入到action里去 直接进的是我建立的test.html 页面

------解决方案--------------------
没问题我在本地运行
  相关解决方案