1、在build path中加入urlrewrite-3.0.4.jar
2、在web.xml中配置一下url重写过滤器,如下:
<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>/android/download/*</url-pattern>
</filter-mapping>
3、在web.xml同级目录下新建一个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>/client/downloadAndroid/(\w+)/(.+)/(.+)</from>
<to>/client/download-android.do?userId=$1&id=$2</to>
</rule>
<rule>
<from>/android/download/(\w+)/(.+)/(.+)</from>
<to>/android/download-android.do?userId=$1&id=$2</to>
</rule>
</urlrewrite>
2、在web.xml中配置一下url重写过滤器,如下:
<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>/android/download/*</url-pattern>
</filter-mapping>
3、在web.xml同级目录下新建一个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>/client/downloadAndroid/(\w+)/(.+)/(.+)</from>
<to>/client/download-android.do?userId=$1&id=$2</to>
</rule>
<rule>
<from>/android/download/(\w+)/(.+)/(.+)</from>
<to>/android/download-android.do?userId=$1&id=$2</to>
</rule>
</urlrewrite>