request.getRequestURI等

it2022-11-28  9

 

装载自:https://blog.csdn.net/gavid0124/article/details/45390999

request.getRequestURL() 返回全路径

request.getRequestURI() 返回除去host(域名或者ip)部分的路径

request.getContextPath() 返回工程名部分,如果工程映射为/,此处返回则为空

request.getServletPath() 返回除去host和工程名部分的路径

 

例如:

request.getRequestURL() http://localhost:8080/jqueryLearn/resources/request.jsp request.getRequestURI() /jqueryLearn/resources/request.jsprequest.getContextPath()/jqueryLearn request.getServletPath()/resources/request.jsp 注: resources为WebContext下的目录名       jqueryLearn 为工程名

转载于:https://www.cnblogs.com/QTSS/p/8671244.html

最新回复(0)