方法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