1、String contextPath = httpServletRequest.getServletContext().getContextPath();
/項目名稱
2、String contextPath2 = httpServletRequest.getContextPath();
/項目名稱
3、String requestURI = httpServletRequest.getRequestURI();
/項目名稱/自定義.jsp
4、StringBuffer requestURL = httpServletRequest.getRequestURL();
http://localhost:8089/項目名稱/自定義.jsp
5、String servletPath = httpServletRequest.getServletPath();
/自定義.jsp
轉載于:https://www.cnblogs.com/zhaoyan001/p/6297346.html