request各个路径方法请求web项目返回的URL:
请求方法:
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String remoteAddress=request.getRemoteAddr();
String servletPath=request.getServletPath();
String realPath=request.getRealPath("/");
String remoteUser=request.getRemoteUser();
String requestURI=request.getRequestURI();
String applicationUrl=application.getContextPath();
返回结果:
path:/springmvc1
basePath:http://localhost:8080/springmvc1/
remoteAddr:0:0:0:0:0:0:0:1
servletPath:/index2.jsp
realPath:F:\springMVC\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc1\
remoteUser:null
requestURI:/springmvc1/index2.jsp
applicationUrl:/springmvc1