煩惱歲月

          付出總是有回報(bào)的 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 不需要解釋 閱讀(198) 評(píng)論(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>
          

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


          網(wǎng)站導(dǎo)航:
           
          我實(shí)話告訴你們,我可是身經(jīng)百戰(zhàn)了.bbs我見的多了,哪個(gè)版我沒(méi)灌過(guò)?你們要知道, 一塌糊 涂的triangle,PIC,SEX版,那比你們不知道厲害到哪里去了,我在那談笑風(fēng)聲.你 們有一好就是無(wú)論在哪個(gè)版,什么話題都灌,但是灌來(lái)灌去的問(wèn)題,都too simple, sometimes naive!你 們懂不懂呀?啊?所以說(shuō)灌水啊,關(guān)鍵是要提高自己的知識(shí)水平.你 們啊,不要總想著弄個(gè)大坑,然后灌上十大,再把我羞辱一番……你們啊,naive!你們這 樣灌是不行地!~那你問(wèn)我支持 不支持灌水,我說(shuō)支持,我常來(lái)這裡灌,你說(shuō)支持不支持?
          主站蜘蛛池模板: 宣恩县| 深泽县| 蒙阴县| 得荣县| 洪湖市| 陈巴尔虎旗| 克山县| 安乡县| 西昌市| 营山县| 平顶山市| 禹城市| 岳西县| 邵武市| 梅河口市| 永靖县| 丽江市| 安阳县| 廊坊市| 万源市| 太和县| 泽州县| 建水县| 双城市| 衡东县| 敖汉旗| 宁阳县| 江都市| 夹江县| 周至县| 卓资县| 云霄县| 大渡口区| 元朗区| 营口市| 南汇区| 乌拉特前旗| 惠州市| 义乌市| 龙泉市| 大埔区|