方法request.getRequestURI()返回具有上下文路徑的URI。如何獲取沒有上下文路徑的請求URI?
例如,如果一個應用程序的基本URL是http://localhost:8080/myapp/
(即上下文路徑是MyApp的),並且我請request.getRequestURI()
爲http://localhost:8080/myapp/secure/users
,它將返回/myapp/secure/users
。
有什麼辦法可以只得到這部分/secure/users
,即沒有上下文路徑的URI?
的可能重複[這是什麼在HttpServletRequest的getRequestURI和getPathInfo方法之間的區別嗎?] (http://stackoverflow.com/questions/4931323/whats-the-difference-between-getrequesturi-and-getpathinfo-methods-in-httpservl) – Leonel 2012-07-06 18:16:18