urlrewriteFilter顺序问题(web.xml)

石湖山庄 发布于 2013/06/08 16:54
阅读 1K+
收藏 0
urlrewrite中,to的type为redirect就成功,但是地址仍然没有成功伪装。而type=forward就报404错误。估计是web.xml配置顺序问题。(在其他项目urlrewrite是正常的。)请问各位大师,web.xml的配置顺序是怎样的? 

我的urlrewrite.xml如下: 

<urlrewrite> 

<rule> 
<note> 
主页重定向1 
此处redirect类型是可以的,但是下面的forward就报404错误 
</note> 
<from>^/nav$</from> 
    <to type="redirect">%{context-path}/websiteNavigationAction!info_list_page.action?pageName=navIndex</to> 
</rule> 

<rule> 
<note> 
主页重定向2 
(此处报错404) 
</note> 
<from>^/navi$</from> 
    <to type="forward">%{context-path}/websiteNavigationAction!info_list_page.action?pageName=navIndex</to> 
</rule> 

<!-- 下面的静态页面也都成功,forward和redirect都行 --> 

<rule> 
<note> 
静态页面1 
</note> 
<from>^/navIndex$</from> 
    <to type="forward">/login.html</to> 
</rule> 

<rule> 
<note> 
静态页面2 
</note> 
<from>^/navIn$</from> 
    <to type="redirect">%{context-path}/page/MyHtml.html</to> 
</rule> 

    <outbound-rule> 
<from>/gdpe_web_system/websiteNavigationAction!info_list_page.action?pageName=navIndex</from> 
<to type="redirect">^/nav\.html$</to> 
</outbound-rule> 

</urlrewrite> 
===================end1==================== 

web.xml 文件如下=================== 

<!-- 顺序为: SetCharacterEncodingFilter、OpenSessionInViewFilter、UrlRewriteFilter、struts2等等--> 

<!-- 统一过滤请求字符集 为UTF-8 begin --> 
<filter> 
<filter-name>setEncoding</filter-name> 
<filter-class>com.gdpe.common.util.custom.SetCharacterEncodingFilter</filter-class> 
<init-param> 
<param-name>setEncoding</param-name> 
<param-value>UTF-8</param-value> 
</init-param> 
</filter> 
<filter-mapping> 
<filter-name>setEncoding</filter-name> 
<url-pattern>/*</url-pattern> 
</filter-mapping> 
<!-- 统一过滤请求字符集 为UTF-8 end --> 

<!-- 会员中心访问控制 begin --> 
<filter> 
<filter-name>memberFolder</filter-name> 
<filter-class>com.gdpe.common.util.custom.FilterMemberFolder</filter-class> 
</filter> 
<filter-mapping> 
<filter-name>memberFolder</filter-name> 
<url-pattern>/websitePage/Member/Control/*</url-pattern> 
</filter-mapping> 
<!-- 会员中心访问控制 end --> 

<display-name>gdpe</display-name> 

<description>gdpe application</description> 
<context-param> 
<param-name>webAppRootKey</param-name> 
<param-value>gdpe.root</param-value> 
</context-param> 

<!-- fresh once every  minutes --> 
<context-param> 
<param-name>log4jRefreshInterval</param-name> 
<param-value>60000</param-value> 
</context-param> 

<!-- 
- Location of the Log4J config file, for initialization and refresh checks. 
- Applied by Log4jConfigListener. 
--> 
<context-param> 
<param-name>log4jConfigLocation</param-name> 
<param-value>/WEB-INF/log4j.properties</param-value> 
</context-param> 

<context-param> 
<param-name>contextConfigLocation</param-name> 
<param-value> 
classpath:applicationContext-base.xml 
classpath:applicationContext-plt-action.xml 
classpath:applicationContext-plt-dao.xml 
classpath:applicationContext-plt-service.xml 
classpath:applicationContext-uum-action.xml 
classpath:applicationContext-uum-dao.xml 
classpath:applicationContext-uum-service.xml 
classpath:applicationContext-web-action.xml 
classpath:applicationContext-web-dao.xml 
classpath:applicationContext-web-service.xml 
</param-value> 
</context-param> 

<!-- OpenSessionInViewFilter =====start --> 
<filter> 
<filter-name>OpenSessionInViewFilter</filter-name> 
<filter-class> 
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter 
</filter-class> 
</filter> 
<filter-mapping> 
<!-- 用于处理hibernate session 事务--> 
<filter-name>OpenSessionInViewFilter</filter-name> 
<url-pattern>/*</url-pattern> 
</filter-mapping> 

<!-- OpenSessionInViewFilter =====end --> 


<!-- 增加的url重写开始 --> 
<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> 
  <dispatcher>REQUEST</dispatcher> 
      <dispatcher>FORWARD</dispatcher> 
</filter-mapping> 

<!-- 增加的url重写结束  --> 



<!-- set before all struts.properties encoding GBK--> 
<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> 
</filter> 



<!-- struts2 config --> 
<filter> 
<filter-name>struts2</filter-name> 
<filter-class> 
org.apache.struts2.dispatcher.FilterDispatcher 
</filter-class> 
</filter> 


<filter> 
<filter-name>CacheFilter</filter-name> 
<filter-class> 
com.opensymphony.oscache.web.filter.CacheFilter 
</filter-class> 
<init-param> 
<param-name>time</param-name> 
<param-value>10</param-value> 
</init-param> 
<init-param> 
<param-name>scope</param-name> 
<param-value>page</param-value> 
</init-param> 
</filter> 


<filter> 
<filter-name>GzipJsFilter</filter-name> 
<filter-class>com.gdpe.common.filter.GzipJsFilter</filter-class> 
<init-param> 
<param-name>headers</param-name> 
<param-value>Content-Encoding=gzip</param-value> 
</init-param> 
</filter> 

<filter-mapping> 
<filter-name>GzipJsFilter</filter-name> 
<url-pattern>*.gzjs</url-pattern> 
</filter-mapping> 


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





<!--  
<filter-mapping> 
<filter-name>CacheFilter</filter-name> 
<url-pattern>*.js</url-pattern> 
</filter-mapping> 
<filter-mapping> 
<filter-name>CacheFilter</filter-name> 
<url-pattern>*.action</url-pattern> 
</filter-mapping> 
--> 

<filter-mapping> 
<filter-name>encodingFilter</filter-name> 
<url-pattern>/*</url-pattern> 
</filter-mapping> 
<filter-mapping> 
<filter-name>struts2</filter-name> 
<url-pattern>*.action</url-pattern> 
</filter-mapping> 

<listener> 
<listener-class> 
org.springframework.web.util.Log4jConfigListener 
</listener-class> 
</listener> 

<!-- 
- Loads the root application context of this web app at startup, 
- by default from "/WEB-INF/applicationContext.xml". 
- Note that you need to fall back to Spring's ContextLoaderServlet for 
- J2EE servers that do not follow the Servlet 2.4 initialization order. 

- Use WebApplicationContextUtils.getWebApplicationContext(servletContext) 
- to access it anywhere in the web application, outside of the framework. 

- The root context is the parent of all servlet-specific contexts. 
- This means that its beans are automatically available in these child contexts, 
- both for getBean(name) calls and (external) bean references. 
--> 

<listener> 
<listener-class> 
org.springframework.web.context.ContextLoaderListener 
</listener-class> 
</listener> 

<!-- Spring 刷新Introspector防止内存泄露 --> 
<listener> 
<listener-class> 
org.springframework.web.util.IntrospectorCleanupListener 
</listener-class> 
</listener> 

<!-- 在线人数统计 --> 
<!-- 
<listener> 
<listener-class> 
com.gdpe.common.listener.OnlineCounterListener 
</listener-class> 
</listener> 
--> 

<!-- 系统集群初始化 --> 
<listener> 
<listener-class> 
com.gdpe.common.listener.InitSystem 
</listener-class> 
</listener> 

<!-- dwr config star --> 
<servlet> 
<servlet-name>dwr-invoker</servlet-name> 
<servlet-class> 
org.directwebremoting.servlet.DwrServlet 
</servlet-class> 
<init-param> 
<param-name>debug</param-name> 
<param-value>true</param-value> 
</init-param> 
<init-param> 
<!--tomcat7 session error--> 
<param-name>crossDomainSessionSecurity</param-name> 
<param-value>false</param-value> 
</init-param> 
<load-on-startup>0</load-on-startup> 
</servlet> 
<!-- ******************************************************************************* --> 
<!-- 数据库连接池 --> 
<!-- ******************************************************************************* --> 
<servlet> 
<servlet-name>Admin</servlet-name> 
<servlet-class> 
org.logicalcobwebs.proxool.admin.servlet.AdminServlet 
</servlet-class> 
</servlet> 

<context-param> 
<param-name> 
org.mortbay.jetty.servlet.ManagedAttributes 
</param-name> 
<param-value>org.cometd.bayeux,dojox.cometd.bayeux</param-value> 
</context-param> 

<servlet> 
<servlet-name>cometd</servlet-name> 
<servlet-class> 
org.mortbay.cometd.continuation.ContinuationCometdServlet 
</servlet-class> 
<init-param> 
<param-name>filters</param-name> 
<param-value>/WEB-INF/filters.json</param-value> 
</init-param> 
<init-param> 
<param-name>timeout</param-name> 
<param-value>120000</param-value> 
</init-param> 
<init-param> 
<param-name>interval</param-name> 
<param-value>0</param-value> 
</init-param> 
<init-param> 
<param-name>maxInterval</param-name> 
<param-value>10000</param-value> 
</init-param> 
<init-param> 
<param-name>multiFrameInterval</param-name> 
<param-value>2000</param-value> 
</init-param> 
<init-param> 
<param-name>logLevel</param-name> 
<param-value>0</param-value> 
</init-param> 
<init-param> 
<param-name>directDeliver</param-name> 
<param-value>true</param-value> 
</init-param> 
<init-param> 
<param-name>refsThreshold</param-name> 
<param-value>10</param-value> 
</init-param> 
<load-on-startup>1</load-on-startup> 
</servlet> 

<servlet-mapping> 
<servlet-name>cometd</servlet-name> 
<url-pattern>/cometd/*</url-pattern> 
</servlet-mapping> 


<servlet-mapping> 
<servlet-name>Admin</servlet-name> 
<url-pattern>/admin</url-pattern> 
</servlet-mapping> 

<servlet-mapping> 
<servlet-name>dwr-invoker</servlet-name> 
<url-pattern>/dwr/*</url-pattern> 
</servlet-mapping> 

<!-- dwr config end --> 

<!-- ckeditor config start --> 
<servlet> 
<servlet-name>ConnectorServlet</servlet-name> 
<servlet-class> 
net.fckeditor.connector.ConnectorServlet 
</servlet-class> 
<load-on-startup>1</load-on-startup> 
</servlet> 

<servlet-mapping> 
<servlet-name>ConnectorServlet</servlet-name> 
<!-- Do not wrap this line otherwise Glassfish will fail to load this file --> 
<url-pattern> 
/fckeditor/editor/filemanager/connectors/* 
</url-pattern> 
</servlet-mapping> 

<!-- ckeditor config end --> 

<!-- filter> 
<filter-name>AccessFilter</filter-name> 
<filter-class> 
com.gdpe.common.filter.AccessControlFilter 
</filter-class> 
</filter> 
<filter-mapping> 
<filter-name>AccessFilter</filter-name> 
<url-pattern>*.action</url-pattern> 
</filter-mapping--> 

<error-page> 
<error-code>404</error-code> 
<location>/websitePage/common/404.jsp</location> 
</error-page> 
<error-page> 
<error-code>500</error-code> 
<location>/websitePage/common/500.jsp</location> 
</error-page> 
<error-page> 
<exception-type>NullPointerException</exception-type> 
<location>/websitePage/common/null.jsp</location> 
</error-page> 

<session-config> 
<session-timeout>60</session-timeout> 
</session-config> 
<!-- 4位验证码 begin --> 
<servlet> 
<servlet-name>ValidateCodeServlet</servlet-name> 
<servlet-class>com.gdpe.common.util.custom.ValidateCodeServlet</servlet-class> 
<init-param> 
<param-name>width</param-name> 
<param-value>72</param-value> 
</init-param> 
<init-param> 
<param-name>height</param-name> 
<param-value>28</param-value> 
</init-param> 
<init-param> 
<param-name>codeCount</param-name> 
<param-value>4</param-value> 
</init-param> 
</servlet> 
<servlet-mapping> 
<servlet-name>ValidateCodeServlet</servlet-name> 
<url-pattern>/validateCodeServlet</url-pattern> 
</servlet-mapping> 
<!-- 4位验证码 end --> 
<!-- 会员在线监听 begin --> 
<listener> 
<listener-class>com.gdpe.common.util.custom.MemberOnlineListener</listener-class> 
</listener> 
<!-- 会员在线监听 end --> 

<distributable /> 

<welcome-file-list> 
<welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 
加载中
返回顶部
顶部