我在我的 java 项目上使用 org.tuuckey.web.filters.urlrewrite.UrlRewriteFilter。它工作正常。我的问题是它更改了现有的 url。
示例我需要将 mainurl/news/cricket 重定向到 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>
关于java - 带有 tomcat 的 UrlRewrite 过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9563884/