request 获取url

一、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

相关文章
相关标签/搜索