2012-03-05 69 views
1

我在我的java项目上使用org.tuckey.web.filters.urlrewrite.UrlRewriteFilter。它工作正常。我的问题是它改变了现有的网址。UrlRewrite过滤器与tomcat

例如我需要重定向mainurl /消息/蟋蟀到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重定向到消息。 jsp/id = 2但我不想更改网址,只更改内容,是否有可能?任何人都知道它是如何做到的。

帮助受到高度赞赏。

谢谢, VKS。

回答

2

然后不要使用重定向。它会发送一个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>