2011-05-06 68 views

回答

2

您可以使用Tuckey Url Rewrite Filter。在那裏你可以定義更復雜的重寫規則。

<!-- I do not know if this fiter works (correctly), but it should 
     demonstrate how it works--> 
<rule> 
    <!-- redirect everything that ends with .css 
     to resources, with same file name --> 
    <from>/(.*)/$.css</from> 
    <to type="redirect">/resouces/$1</to> 
</rule> 
+0

有趣。有什麼方法可以使用servlet上下文進行重寫?例如, 'http:// localhost:8080/myContext/anyUser/css/ie.css'到'http:// localhost:8080/myContext/css/ie.css'? 所有的例子似乎直接映射到根。防爆。 'http:// localhost:8080/myContext/anyUser/css/ie.css'到'http:// localhost:8080/css/ie.css' – rreyes1979 2011-05-06 16:18:27

+0

Tuckey Url Rewrite Filter可以在你的應用程序中工作,所以你不能重寫到其他應用程序。 – Ralph 2011-05-08 08:39:13

+1

其實,你可以和那個在你的例子中「重定向」時發生的事情。正確的規則應該是這樣的: \t' \t \t +/CSS /(.*)$ \t \t <爲type = 「前進」 最後= 「真」>/CSS/$ 1 \t' – rreyes1979 2011-05-09 00:57:19