假设项目根路径为/home/project/bbb,当前URL为http://www.aaa.com/bbb/ccc/ddd.html
request.getRequestURI()=/bbb/ccc/ddd.html
request.getRequestURL()=http://www.aaa.com/bbb/ccc/ddd.html
request.getContextPath=bbb
request.getServletContext().getContextPath=bbb
假设项目根路径为/home/project/bbb,当前URL为http://www.aaa.com/bbb/ccc/ddd.html
request.getRequestURI()=/bbb/ccc/ddd.html
request.getRequestURL()=http://www.aaa.com/bbb/ccc/ddd.html
request.getContextPath=bbb
request.getServletContext().getContextPath=bbb
转载于:https://my.oschina.net/xiaoqqq/blog/301697