一一对应。。
System.out.println("-----ServletPath---" + request.getServletPath()); System.out.println("-----ContextPath---" + request.getContextPath()); System.out.println("-----referer---" + request.getHeader("referer")); System.out.println("-----host---" + request.getHeader("host")); System.out.println("-----RequestURI---" + request.getRequestURI()); System.out.println("-----RequestURL---" + request.getRequestURL()); System.out.println("-----ServerName---" + request.getServerName()); System.out.println("-----ServerPort---" + request.getServerPort()); String realPath1 = "http://"+ request.getServerName()+ ":"+ request.getServerPort()+ request.getContextPath()+ request.getServletPath().substring(0,request.getServletPath().lastIndexOf("/") + 1); System.out.println("web URL 路径:" + realPath1); -----ServletPath---/payment/payment.do -----ContextPath--- -----referer---http://127.0.0.1/payment/payment.do?uid=37bf12f198be26dd1bc6395af5732e0d&v=1&cardType=SZX&cardNumber=dgf&amount=1 -----host---127.0.0.1 -----RequestURI---/payment/payment.do -----RequestURL---http://127.0.0.1/payment/payment.do -----ServerName---127.0.0.1 -----ServerPort---80 web URL 路径:http://127.0.0.1:80/payment/