使用 URLRewrite 重寫URL

2021-05-25 01:27:03 字數 546 閱讀 1115

1、測試環境

/web-inf/下,注意不要修改urlrewrite.xml檔名。

2、修改web.xml

在web.xml中增加filter配置:

其中 是定製的規則,是顯示的url,是真正請求的url。type = "forward" 位址列顯示from部分(靜態化url),type="redirect",位址列顯示to部分(真正請求的位址),注意要保證路徑的正確。規則的定製支援正規表示式 (如rule 2)。

4、測試

測試環境檔案目錄

webroot

---web-inf

---urlrewrite.xml

---login.jsp

啟動服務,位址列輸入http://localhost:port/***/login.html

rule 1:實際請求為http://localhost:port/***/login.jsp

rule 2:實際請求為http://localhost:port/***/login.jsp?id=login

總結:要熟悉正規表示式的運用

URLRewrite實現偽靜態 url重寫

urlrewritefilter org.tuckey.web.filters.urlrewrite.urlrewritefilter 4.修改urlrewrite.xml a z world.jsp?id 1 world world.jsp?tid 1 html test1 1.jsp the o...

urlrewrite使用案例

urlrewrite字面意思為重寫路徑,可以改變瀏覽器中我們看得到的 url路徑,而且有得於搜尋引擎抓取,form表單 ajax都不利於搜尋引擎抓取。1 我用的是目前最新的版本4.0.4 org.tuckey urlrewritefilter 4.0.4 2 在web.xml中配置乙個過濾器,用來過...

UrlRewrite 關於位址重寫來增加安全性

urlrewrite 關於位址重寫來增加安全性 一 urlrewrite的基本環境搭建 首先匯入 urlrewrite 3.2.0.jar包,然後在web.xml裡面宣告filter urlrewritefilter org.tuckey.web.filters.urlrewrite.urlrewr...