最近用到这个东西,查阅后记录一下笔记。
request.getRequestURL()-----------返回全路径
request.getRequestURI()-----------返回除去host(域名或者ip)部分的路径
request.getContextPath()----------返回工程名部分,如果工程映射为/,此处返回则为空
request.getServletPath()-----------返回除去host和工程名部分的路径
[tip type="warning"]
相关文章
[/tip]
例如:
request.getRequestURL()----------- http://localhost:8080/jqueryLearn/resources/request.jsp
request.getRequestURI()----------- /jqueryLearn/resources/request.jsp
request.getContextPath()---------- /jqueryLearn
request.getServletPath()-----------/resources/request.jsp
[tip type="warning"]
注: resources为WebContext下的目录名
jqueryLearn 为工程名
[/tip]
版权属于:乐心湖's Blog
本文链接:https://www.xn2001.com/archives/376.html
声明:博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!