Request參數總結
- 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();
- out.println("path:"+path+"<br>");
- out.println("basePath:"+basePath+"<br>");
- out.println("remoteAddr:"+remoteAddress+"<br>");
- out.println("servletPath:"+servletPath+"<br>");
- out.println("realPath:"+realPath+"<br>");
- out.println("remoteUser:"+remoteUser+"<br>");
- out.println("requestURI:"+requestURI+"<br>");
- 結果:
- path:/springboot
- basePath:http://localhost:8080/springboot/
- remoteAddr:127.0.0.1
- servletPath:/index.jsp
- realPath:E:\apache-tomcat-8.0.23\webapps\springboot\
- remoteUser:null
- requestURI:/springboot/index.jsp
- 從上不難看出request各個對應方法所表明的含義
歡迎關注本站公眾號,獲取更多信息