溫馨提示:您的每一次轉載,體現了我寫此文的意義!!!煩請您在轉載時注明出處http://www.aygfsteel.com/sxyx2008/謝謝合作!!!

          雪山飛鵠

          溫馨提示:您的每一次轉載,體現了我寫此文的意義!!!煩請您在轉載時注明出處http://www.aygfsteel.com/sxyx2008/謝謝合作!!!

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            215 Posts :: 1 Stories :: 674 Comments :: 0 Trackbacks
          JAR版本:urlrewrite-3.2.0.jar
          web.xml配置
              <filter>
                  
          <filter-name>UrlRewriteFilter</filter-name>
                  
          <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
                  
          <init-param>
                      
          <param-name>confReloadCheckInterval</param-name>
                      
          <param-value>60</param-value>
                  
          </init-param>
                  
          <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>
                   
          <dispatcher>REQUEST</dispatcher>
                   
          <dispatcher>FORWARD</dispatcher>
                   
          <url-pattern>/*</url-pattern>
               
          </filter-mapping>
          urlrewrite.xml
          <?xml version="1.0" encoding="utf-8"?>
          <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
                  "http://tuckey.org/res/dtds/urlrewrite3.2.dtd"
          >

          <!--

              Configuration file for UrlRewriteFilter
              http://tuckey.org/urlrewrite/

          -->
          <urlrewrite> 
              
          <!-- 
                  匹配地址為
                  形如/content/94/list的地址將跳轉到
                  /IssuedContentAction.do?dispatch=vContentListBySubid&amp;scope=vmcontent&amp;columninfoid=$1
              
          -->
              
          <rule>
                  
          <!-- 地址欄顯示的地址 -->
                  
          <from>/content/([0-9]+)/list</from>  
                  
          <!-- 真實的請求地址 -->
                  
          <to type="forward">/IssuedContentAction.do?dispatch=vContentListBySubid&amp;scope=vmcontent&amp;columninfoid=$1</to>
              
          </rule>
              
          <!--

              INSTALLATION

                  in your web.xml add

                  <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>

               EXAMPLES

               Redirect one url
                  <rule>
                      <from>/some/old/page.html</from>
                      <to type="redirect">/very/new/page.html</to>
                  </rule>

              Redirect a directory
                  <rule>
                      <from>/some/olddir/(.*)</from>
                      <to type="redirect">/very/newdir/$1</to>
                  </rule>

              Clean a url
                  <rule>
                      <from>/products/([0-9]+)</from>
                      <to>/products/index.jsp?product_id=$1</to>
                  </rule>
              eg, /products/1234 will be passed on to /products/index.jsp?product_id=1234 without the user noticing.

              Browser detection
                  <rule>
                      <condition name="user-agent">Mozilla/[1-4]</condition>
                      <from>/some/page.html</from>
                      <to>/some/page-for-old-browsers.html</to>
                  </rule>
              eg, will pass the request for /some/page.html on to /some/page-for-old-browsers.html only for older
              browsers whose user agent srtings match Mozilla/1, Mozilla/2, Mozilla/3 or Mozilla/4.

              Centralised browser detection
                  <rule>
                      <condition name="user-agent">Mozilla/[1-4]</condition>
                      <set type="request" name="browser">moz</set>
                  </rule>
              eg, all requests will be checked against the condition and if matched
              request.setAttribute("browser", "moz") will be called.

              
          -->

          </urlrewrite>
          注意:
          1、多個參數之間的連接符要用&amp;而不是&
          2、匹配從應用程序的名稱開始匹配

          瀏覽器中顯示的請求地址(請求鏈接中填寫的地址)
          /content/91/list
          真正的請求地址
          /IssuedContentAction.do?dispatch=vContentListBySubid&scope=vmcontent&columninfoid=91


          posted on 2011-11-24 11:48 雪山飛鵠 閱讀(943) 評論(0)  編輯  收藏 所屬分類: struts2
          主站蜘蛛池模板: 长沙县| 明水县| 温泉县| 迁西县| 淳化县| 龙江县| 合水县| 和林格尔县| 温泉县| 通榆县| 盐山县| 鹿泉市| 霍州市| 翁牛特旗| 花莲县| 合川市| 庆云县| 五大连池市| 正蓝旗| 绵竹市| 仙居县| 翼城县| 周口市| 巩留县| 南阳市| 宜君县| 德惠市| 花垣县| 弥渡县| 南宫市| 调兵山市| 焦作市| 昌宁县| 玛纳斯县| 通榆县| 江阴市| 辉南县| 新绛县| 固安县| 太保市| 江川县|