Distinguish between different methods of obtaining the request through the request path differences by different methods of obtaining request of the request path

Distinguish between different methods of obtaining the request through the request path

1, request.getRequestURL () returns the complete url, including Http protocol, port number, and the name of the servlet map path, but it does not include the requested parameter.

2, request.getRequestURI () is part of the value obtained in the request URL, the container and the web had not decode

3、request.getContextPath() 返回 the context of the request.

4, request.getServletPath () returns the part of the url calling servlet.

5, request.getQueryString () Returns the path of the query string behind url

 

Example: The current url: http: // localhost:? 8080 / CarsiLogCenter_new / idpstat.jsp action = idp.sptopn

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.sptopn

1, request.getRequestURL () returns the complete url, including Http protocol, port number, and the name of the servlet map path, but it does not include the requested parameter.

2, request.getRequestURI () is part of the value obtained in the request URL, the container and the web had not decode

3、request.getContextPath() 返回 the context of the request.

4, request.getServletPath () returns the part of the url calling servlet.

5, request.getQueryString () Returns the path of the query string behind url

 

Example: The current url: http: // localhost:? 8080 / CarsiLogCenter_new / idpstat.jsp action = idp.sptopn

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.sptopn

Guess you like

Origin www.cnblogs.com/meizhoulqp/p/12144334.html