關於request.getServletPath(),request.getContextPath()的總結
阿新 • • 發佈:2018-11-06
https://blog.csdn.net/qq_27770257/article/details/79438987
通過觀察列印結果,我們可以總結:
1. getServletPath():獲取能夠與“url-pattern”中匹配的路徑,注意是完全匹配的部分,*的部分不包括。
2. getPageInfo():與getServletPath()獲取的路徑互補,能夠得到的是“url-pattern”中*d的路徑部分
3. getContextPath():獲取專案的根路徑
4. getRequestURI:獲取根路徑到地址結尾
5. getRequestURL:獲取請求的地址連結(瀏覽器中輸入的地址)
6. getServletContext().getRealPath(“/”):獲取“/”在機器中的實際地址
7. getScheme():獲取的是使用的協議(http 或https)
8. getProtocol():獲取的是協議的名稱(HTTP/1.11)
9. getServerName():獲取的是域名(xxx.com)
10. getLocalName:獲取到的是IP
---------------------
作者:jwnba24
來源:CSDN
原文:https://blog.csdn.net/qq_27770257/article/details/79438987
版權宣告:本文為博主原創文章,轉載請附上博文連結!