日期:2022-08-31  浏览次数:90 次

假如请求的URL是 http://localhost:8080/test/index.jsp

//输出:http
request.getScheme()  

//输出: localhost
request.getServerName()  
 
 //输出: 8080
request.getServerPort() 
 
  //输出: /test
request.getContextPath() 
 
 //输出: /index.jsp
request.getRequestPath() 
 
 //输出:  /test/index.jsp
request.gerRequestURI() 
 
 //输出: http://localhost:8080/test/index.jsp
request.getRequestURL() 
 
 //输出:E:\apache-tomcat-8.0.10\webapps\test
request.getRealPath("")