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