请求:http://ip:8080/HelloWeb/index.jsp?name=linwen&password=123456
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
String remoteAddress=request.getRemoteAddr();
String servletPath=request.getServletPath();
String remoteUser=request.getRemoteUser();
String requestURI=request.getRequestURI();
String queryString = request.getQueryString();
path:/HelloWeb
basePath:http://192.168.230.143:8080
remoteAddr:192.168.230.143 :IP地址
servletPath:/index.jsp :读取除掉根路径
remoteUser:null
requestURI:/HelloWeb/index.jsp :把项目的根路径读取
queryString:name=linwen&password=123456
所以,想要获取链接,拼接即可(在服务器内部重定向不需要拼接域名)