2012-03-05 47 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>