【转帖】【Web】HttpServletRequest request 相关方法 得到路径

username=qqqq

password=wwww

//----------------------POST------------------->

http://192.168.1.211:8080/demo/index.jsp

request.getContextPath() =/demo

request.getMethod() =POST

request.getRequestURI() =/demo/reg

request.getRequestURL() =http://192.168.1.211:8080/demo/reg

request.getServletPath() =/reg

//-----------------------GET------------------->

http://192.168.1.211:8080/demo/index.jsp?username=1&password=1&email=1

request.getContextPath() =/demo

request.getMethod() =GET

request.getQueryString() =username=1&password=1&email=1

request.getRequestURI() =/demo/index.jsp

request.getRequestURL() =http://192.168.1.211:8080/demo/index.jsp

request.getServletPath() =/index.jsp

你可能感兴趣的:(java)