jsp获取url路径的方法


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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM