导入urlrewritefilter.jar包
<dependency>
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
<version>4.0.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
配置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文件
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
<outbound-rule encodefirst="true">
<from>^(.*);jsessionid=.*$</from>
<to>$1</to>
</outbound-rule>
<outbound-rule match-type="wildcard">
<from>*;jsessionid=*</from>
<to>$1</to>
</outbound-rule>
</urlrewrite>
转载 http://ltgltg.blog.163.com/blog/static/17393743720120631255520/