首页 > Web开发 > 详细

jsp获取url路径的方法

时间:2019-05-19 13:53:44      阅读:131      评论:0      收藏:0      [点我收藏+]

如果你请求的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

 

jsp获取url路径的方法

原文:https://www.cnblogs.com/jiangfeilong/p/10888978.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!