我在java项目中使用org.tuckey.web.filters.urlrewrite.UrlRewriteFilter。它工作得很好。我的问题是它改变了现有的url。
例如,我需要将mainurl/news/clicket重定向到mainurl/news.jsp/id=2
myurlrewriter.xml
<rule>
<note>
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
</note>
<from>/news/cricket</from>
<to type="redirect">%{context-path}/news.jsp/id=2</to>
</rule>
它将整个url重定向到news.jsp/id=2,但我不想更改url,只想更改内容,这可能吗?任何人都知道怎么做。
我们非常感谢您的帮助。
谢谢,VKS。
然后不要使用重定向。它将发送一个302,这意味着它告诉浏览器页面已经移动。失去type="redirect"
:
<rule>
<note>
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
</note>
<from>/news/cricket</from>
<to>/news.jsp/id=2</to>
</rule>