煩惱歲月

          付出總是有回報的 take action follow your heart , or follow your head
          posts - 40, comments - 5, trackbacks - 0, articles - 4

          url rewirter filter

          Posted on 2009-05-24 16:15 不需要解釋 閱讀(197) 評論(0)  編輯  收藏

          Based on the popular and very useful mod_rewrite for apache, UrlRewriteFilter is a Java Web Filter for any J2EE compliant web application server (such as Resin, Orion or Tomcat), which allows you to rewrite URLs before they get to your code. It is a very powerful tool just like Apache's mod_rewrite.

          URL rewriting is very common with Apache Web Server (see ) but has not been possible in most java web application servers. The main things it is used for are:

          • URL Tidyness / URL Abstraction - keep URLs tidy irrespective of the underlying technology or framework (JSP, Servlet, Struts etc).
          • Browser Detection - Allows you to rewrite URLs based on request HTTP headers (such as user-agent or charset).
          • Date based rewriting - Allows you to forward or redirect to other URL's based on the date/time (good for planned outages).
          • Moved content - enable a graceful move of content or even a change in CMS.
          • Tiny/Friendly URL's (i.e. blah.com/latest can be redirected to blah.com/download/ver1.2.46.2/setup.exe)
          • A Servlet mapping engine (see Method Invocation)

          UrlRewriteFilter uses an xml file, called urlrewrite.xml (it goes into the WEB-INF directory), for configuration. Most parameters can be Perl5 style Regular Expressions or Wildcard Expressions. This makes it very powerful indeed.

           

          example:

          web.xml

            <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>
          
          urlrewrite.xml
          <?xml version="1.0" encoding="utf-8"?>
          
              <!DOCTYPE urlrewrite
                  PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN"
                  "http://tuckey.org/res/dtds/urlrewrite3.0.dtd">
          
              <urlrewrite>
                  <rule>
                     <from>^/some/olddir/(.*)$</from>
                     <to type="redirect">/very/newdir/$1</to>
                  </rule>
          
                  <rule match-type="wildcard">
                     <from>/blog/archive/**</from>
                     <to type="redirect">/roller/history/$1</to>
                  </rule>
              </urlrewrite>
          

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


          網站導航:
           
          我實話告訴你們,我可是身經百戰了.bbs我見的多了,哪個版我沒灌過?你們要知道, 一塌糊 涂的triangle,PIC,SEX版,那比你們不知道厲害到哪里去了,我在那談笑風聲.你 們有一好就是無論在哪個版,什么話題都灌,但是灌來灌去的問題,都too simple, sometimes naive!你 們懂不懂呀?啊?所以說灌水啊,關鍵是要提高自己的知識水平.你 們啊,不要總想著弄個大坑,然后灌上十大,再把我羞辱一番……你們啊,naive!你們這 樣灌是不行地!~那你問我支持 不支持灌水,我說支持,我常來這裡灌,你說支持不支持?
          主站蜘蛛池模板: 红桥区| 鄢陵县| 浦城县| 永新县| 积石山| 平利县| 阳城县| 鄂托克旗| 怀化市| 扎囊县| 荔浦县| 信宜市| 磴口县| 房产| 合水县| 阳新县| 南涧| 绥滨县| 滨州市| 靖州| 浦东新区| 罗平县| 清河县| 象州县| 大理市| 汾西县| 阿鲁科尔沁旗| 建昌县| 保德县| 盘锦市| 文安县| 都安| 鲜城| 清水县| 黄陵县| 枣阳市| 镇江市| 阿图什市| 海淀区| 新化县| 清河县|