一:首先在到官方站点下载最新的jar文件
http://tuckey.org/urlrewrite/manual/3.0/
二:在web.xm中加上如下的filter
xml 代码
- <filter>
- <filter-name>UrlRewriteFilterfilter-name>
- <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilterfilter-class>
- filter>
- <filter-mapping>
- <filter-name>UrlRewriteFilterfilter-name>
- <url-pattern>/*url-pattern>
- filter-mapping>
三:创建匹配的规则
我们这里的就是要的是根据不同的用户,转到不同的页面去,
如:
转到
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>^/user/(.*)$</from>
- <to type="forward">/portal.html\?username=$1</to>
- </rule>
- </urlrewrite>
分享到:
相关推荐
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <param-name>logLevel <param-value>WARN <param-name>statusEnabled <param-value>true </filter> <filter-...
集成`URLrewrite`到Java Web应用中,通常需要在web.xml中配置Filter,指定`urlrewrite.xml`的位置,然后在Servlet容器启动时加载配置: ```xml <filter> <filter-name>UrlRewriteFilter</filter-name> <filter-...
2. 配置web.xml:在`web.xml`中添加`Filter`和`Filter-Mapping`,以启动`urlrewrite`过滤器。 3. 编写urlrewrite.xml:这是URL重写的核心配置文件,定义了各种URL重写规则。 4. 测试与调试:运行项目,通过浏览器...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> </filter-...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <param-name>logLevel <param-value>info </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> ...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <!-- 设置自动更新urlrewrite.xml信息 --> <param-name>confReloadCheckInterval <param-value>60 </filter> <filter-...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <param-name>logLevel <param-value>DEBUG <param-name>confFile <param-value>/WEB-INF/urlrewrite.xml </filter>...
- 在Web应用服务器中配置URLRewrite Filter。 - 测试并调整规则,确保URL重写效果符合预期。 5. 示例代码: 以下是一个简单的URL重写规则示例,将所有以“/product?id=”开头的请求转换为“/product/”格式: `...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <param-name>logLevel <param-value>info <param-name>statusPath <param-value>/urlrewrite-status </filter> ...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <param-name>logLevel <param-value>WARN <param-name>statusEnabled <param-value>true </filter> <filter-...
DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN" "http://tuckey.org/res/dtds/urlrewrite2.6.dtd"> <urlrewrite> ^/([0-9]+).html$ <to type="forward">/index.jsp?id=$1 </urlrewrite> ...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <param-name>logLevel <param-value>WARN </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> ...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <param-name>logLevel <param-value>WARN <param-name>confFile <param-value>/WEB-INF/urlrewrite.xml </filter> ...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>...
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/member/*</url-pattern> </...