如果你请求的URL是  http://localhost:8080/demo/Index.jsp

request.getScheme()  //输出:http
 
request.getServerName()  //输出: localhost
 
request.getServerPort() //输出: 8080
 
request.getContextPath()  //输出: /demo
 
request.getRequestPath() //输出: /Index.jsp
 
request.gerRequestURI() //输出:  /demo/Index.jsp
 
request.getRequestURL() //输出: http://localhost:8080/demo/Index.jsp
 
request.getRealPath("") //输出:D:\apache-tomcat-6.0.10\webapps\demo

 

相关文章:

  • 2022-03-02
  • 2021-12-16
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2021-11-30
  • 2022-12-23
  • 2021-06-26
  • 2022-02-21
  • 2021-08-28
  • 2021-11-30
相关资源
相似解决方案