明天的明天的明天

          用鍵盤改變生活

            BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            17 Posts :: 0 Stories :: 19 Comments :: 0 Trackbacks
          首先要在web.xml中聲明一個Filter
           <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>

          然后在WEB-INF目錄下新建urlrewrite.xml
          在其中進(jìn)行重寫規(guī)則的定義,它使用正則表達(dá)式來進(jìn)行規(guī)則的定義

          <?xml version="1.0" encoding="utf-8"?>
          <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"
                  "

          <!--

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

          -->
          <urlrewrite>

                  <rule>
                      <from>/test.html</from>
                      <to type="redirect">%{context-path}/page.html</to>
                  </rule>

                  <rule>
                      <from>/param/(.*)</from>
                      <to>/param.jsp?param=$1</to>
                  </rule>

          </urlrewrite>

          上面是我的一個簡單的測試
                  <rule>
                      <from>/test.html</from>
                      <to type="redirect">%{context-path}/page.html</to>
                  </rule>
          是將test.html的訪問請求轉(zhuǎn)發(fā)給page.html

                  <rule>
                      <from>/param/(.*)</from>
                      <to>/param.jsp?param=$1</to>
                  </rule>
          將param.jsp?param=111這種請求重寫為/param/111

          里面有詳細(xì)的例子,大家可以自己看下
          posted on 2007-09-17 12:52 Endless 閱讀(533) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 什邡市| 东平县| 洛南县| 麦盖提县| 济南市| 电白县| 元谋县| 衡阳市| 邵东县| 克山县| 双城市| 玛纳斯县| 雅江县| 鹤岗市| 溧水县| 平罗县| 清镇市| 安陆市| 历史| 红安县| 洪雅县| 晋中市| 安阳市| 凤庆县| 肃宁县| 衡阳市| 雷山县| 呼伦贝尔市| 昭觉县| 银川市| 和田市| 大城县| 临西县| 台中市| 石柱| 万源市| 清远市| 溧阳市| 通道| 巫山县| 农安县|