一、request.getRequestURL()web
返回的是完整的url,包括Http協議,端口號,servlet名字和映射路徑,但它不包含請求參數。
二、request.getRequestURI()jsp
獲得的是request URL的部分值,而且web容器沒有decode過的url
三、request.getContextPath()
返回 the context of the request.code
四、request.getServletPath()
返回調用servlet的部分url.字符串
五、request.getQueryString()
返回url路徑後面的查詢字符串get
示例:servlet
當前url:http://localhost:8080/CarsiLogCenter_new/idpstat.jsp?action=idp.sptopnio
request.getRequestURL() http://localhost:8080/CarsiLogCenter_new/idpstat.jsp
request.getRequestURI() /CarsiLogCenter_new/idpstat.jsp
request.getContextPath()/CarsiLogCenter_new
request.getServletPath() /idpstat.jsp容器
request.getQueryString()action=idp.sptopnrequest