访问请求localhost:8080/menus跳转到localhost:8080/menus/home
依赖的jar包
<dependency>
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
<version>4.0.4</version>
</dependency>
配置在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>
</filter-mapping>
UrlRewriteFilter.xml文件放在webapp/WEB-INF/下面,配置相应的请求重定向。
<?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 default-match-type="wildcard">
<rule>
<from>/menus</from>
<to>/menus/home</to>
</rule>
<rule>
<from>/menus/</from>
<to>/menus/home</to>
</rule>
</urlrewrite>