【问题标题】:UrlRewrite filter with tomcat使用 tomcat 的 UrlRewrite 过滤器
【发布时间】:2012-03-22 18:16:56
【问题描述】:

我在我的 java 项目上使用 org.tukey.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。

【问题讨论】:

    标签: java tomcat url-rewriting


    【解决方案1】:

    那么不要使用重定向。它将发送一个 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>
    

    【讨论】:

      猜你喜欢
      • 2011-12-04
      • 2012-10-27
      • 2013-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-08
      • 2012-01-09
      相关资源
      最近更新 更多