Request參數總結

  

  1. String path = request.getContextPath();  
  2. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";  
  3. String remoteAddress=request.getRemoteAddr();  
  4. String servletPath=request.getServletPath();  
  5. String realPath=request.getRealPath("/");  
  6. String remoteUser=request.getRemoteUser();  
  7. String requestURI=request.getRequestURI();  
  8. out.println("path:"+path+"<br>");  
  9. out.println("basePath:"+basePath+"<br>");  
  10. out.println("remoteAddr:"+remoteAddress+"<br>");  
  11. out.println("servletPath:"+servletPath+"<br>");  
  12. out.println("realPath:"+realPath+"<br>");  
  13. out.println("remoteUser:"+remoteUser+"<br>");  
  14. out.println("requestURI:"+requestURI+"<br>");  
  15. 結果:  
  16. path:/springboot
  17. basePath:http://localhost:8080/springboot/  
  18. remoteAddr:127.0.0.1  
  19. servletPath:/index.jsp  
  20. realPath:E:\apache-tomcat-8.0.23\webapps\springboot\  
  21. remoteUser:null  
  22. requestURI:/springboot/index.jsp  
  23. 從上不難看出request各個對應方法所表明的含義 
相關文章
相關標籤/搜索