当前位置: 代码迷 >> Web前端 >> urlrewrite应用
  详细解决方案

urlrewrite应用

热度:803   发布时间:2012-10-29 10:03:53.0
urlrewrite使用
一、web.xml配置加如下:
<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
内容:
<?xml version="1.0" encoding="utf-8"?>   
<urlrewrite>   
    <rule>   
        <note>   
        </note>   
        <from>^/([0-9A-Za-z]+)$</from>   
        <to type="forward">/servlet/Test1?id=$1</to>   
    </rule>   
</urlrewrite> 

?