我想使用urlrewritefilter去实现url rewrite。可是配置总是无法实现,各位大大帮我看看怎么回事第一步:我在我的程序文件夹中的web\web-inf中建立一个文件urlrewrite.xml 然后在里面添加:
<urlrewrite>
<rule>
<note>
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
</note>
<from>/test/status/</from>
<to type="redirect">%{context-path}/rewrite-status</to>
</rule> <outbound-rule>
<note>
The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
the url /rewrite-status will be rewritten to /test/status/. The above rule and this outbound-rule means that end users should never see the
url /rewrite-status only /test/status/ both in thier location bar and in hyperlinks
in your pages.
</note>
<from>/rewrite-status</from>
<to>/test/status/</to>
</outbound-rule>第二步:在程序文件夹中的web/web-inf中建立一个文件夹lib。然后拷贝jar文件urlrewrite-3.0.4.jar到这个目录下第三步:建了一个测试的jsp文件index.jsp。这个文件内容是:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h2>Hello World!</h2>
<a href="/test/status/">test</a>
</body>
</html>然后重启tomcat。不知道为什么怎么也无法实现url rewrite。在显示的页面上链接“test”的地址还是:http://localhost:8084/test/status/我很急啊,希望各位大大赐教啊,求你了!!!
<urlrewrite>
<rule>
<note>
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
</note>
<from>/test/status/</from>
<to type="redirect">%{context-path}/rewrite-status</to>
</rule> <outbound-rule>
<note>
The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
the url /rewrite-status will be rewritten to /test/status/. The above rule and this outbound-rule means that end users should never see the
url /rewrite-status only /test/status/ both in thier location bar and in hyperlinks
in your pages.
</note>
<from>/rewrite-status</from>
<to>/test/status/</to>
</outbound-rule>第二步:在程序文件夹中的web/web-inf中建立一个文件夹lib。然后拷贝jar文件urlrewrite-3.0.4.jar到这个目录下第三步:建了一个测试的jsp文件index.jsp。这个文件内容是:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h2>Hello World!</h2>
<a href="/test/status/">test</a>
</body>
</html>然后重启tomcat。不知道为什么怎么也无法实现url rewrite。在显示的页面上链接“test”的地址还是:http://localhost:8084/test/status/我很急啊,希望各位大大赐教啊,求你了!!!
<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>
...
<from>/rewrite-status </from>
<to>/test/status/ </to>
</outbound-rule>
你这设的有问题吧?
http://www.webwoo.net/bc/bencandy-11-29911-1.htm
如: <rule>
<from>/login.htm</from>
<to type="redirect">http://localhost:8080/yourproject/</to>
</rule>
明白了?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h2>Hello World!</h2>
<a href="/test/status/">test</a>
</body>
</html>你给我的urlrewrite.xml中包含两个rule:<urlrewrite> <rule>
<from>/test/status/ </from>
<to type="redirect">%{context-path}/index.jsp </to>
</rule>
<outbound-rule>
<from>/index.jsp</from>
<to>/test/status/ </to>
</outbound-rule>
</urlrewrite>我就在index.jsp中加了一个连接“test”,看看是否可以rewrite,可结果还是http://localhost:8084/test/status/。
该怎么办啊,烦死了。