用鍵盤改變生活
然后在WEB-INF目錄下新建urlrewrite.xml 在其中進行重寫規則的定義,它使用正則表達式來進行規則的定義
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN" " <!-- Configuration file for UrlRewriteFilter http://tuckey.org/urlrewrite/ --> <urlrewrite> <rule> <from>/test.html</from> <to type="redirect">%{context-path}/page.html</to> </rule> <rule> <from>/param/(.*)</from> <to>/param.jsp?param=$1</to> </rule> </urlrewrite> 上面是我的一個簡單的測試 <rule> <from>/test.html</from> <to type="redirect">%{context-path}/page.html</to> </rule> 是將test.html的訪問請求轉發給page.html <rule> <from>/param/(.*)</from> <to>/param.jsp?param=$1</to> </rule> 將param.jsp?param=111這種請求重寫為/param/111 里面有詳細的例子,大家可以自己看下
<!--
Configuration file for UrlRewriteFilter http://tuckey.org/urlrewrite/
--> <urlrewrite> <rule> <from>/test.html</from> <to type="redirect">%{context-path}/page.html</to> </rule> <rule> <from>/param/(.*)</from> <to>/param.jsp?param=$1</to> </rule> </urlrewrite>
上面是我的一個簡單的測試 <rule> <from>/test.html</from> <to type="redirect">%{context-path}/page.html</to> </rule> 是將test.html的訪問請求轉發給page.html
<rule> <from>/param/(.*)</from> <to>/param.jsp?param=$1</to> </rule> 將param.jsp?param=111這種請求重寫為/param/111
Copyright @ Endless Powered by: .Text and ASP.NET Theme by: .NET Monster