Web应用中request获取各种获取path或URI,URL的方法
Web應用中有各種獲取path或URI,URL的方法,假設網頁訪問地址:
http://localhost:8080/tradeload/TestServlet
Web應用context: /tradeload?
各路徑鑒定如下:
request.getContextPath()= /tradeload
request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()= http://localhost:8080
request.getRequestURL() = http://localhost:8080/tradeload/TestServlet
request.getRequestURI() = /tradeload/TestServlet
request.getPathInfo() = null
request.getServletPath() = /TestServlet
getServletContext().getRealPath('/') = C:\server\glassfish\domains\domain1\applications\j2ee-modules\tradeload\
?
原文出處:http://improve.iteye.com/blog/741427
?
轉載于:https://www.cnblogs.com/chenlei123/p/5657066.html
總結
以上是生活随笔為你收集整理的Web应用中request获取各种获取path或URI,URL的方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ubuntu装指定分区_安装Ubuntu
- 下一篇: Alsa中PCM参数设置