HttpServletRequest 的各种方法的返回值

System.out.println("ContextPath: " + hsq.getContextPath());
System.out.println("LocalAddr: " + hsq.getLocalAddr());
System.out.println("LocalName: " + hsq.getLocalName());
System.out.println("LocalPort: " + hsq.getLocalPort());
System.out.println("PathInfo: " + hsq.getPathInfo());
System.out.println("Protocol: " + hsq.getProtocol());
System.out.println("QueryString: " + hsq.getQueryString());
System.out.println("RemoteAddr: " + hsq.getRemoteAddr());
System.out.println("RemoteHost: " + hsq.getRemoteHost());
System.out.println("RemotePort: " + hsq.getRemotePort());
System.out.println("RequestURI: " + hsq.getRequestURI());
System.out.println("Scheme: " + hsq.getScheme());
System.out.println("ServerName: " + hsq.getServerName());
System.out.println("ServerPort: " + hsq.getServerPort());
System.out.println("ServletPath: " + hsq.getServletPath());
System.out.println("RequestURL: " + hsq.getRequestURL());

 

测试用 请求地址(自己访问自己本地搭建的服务器):

http://127.0.0.1:8089//mgems/sv/RABAs016

 

结果为:

ContextPath: /mgems
LocalAddr: 127.0.0.1
LocalName: 127.0.0.1
LocalPort: 8089
PathInfo: /RABAs016
Protocol: HTTP/1.1
QueryString: null
RemoteAddr: 127.0.0.1
RemoteHost: 127.0.0.1
RemotePort: 49515
RequestURI: /mgems/sv/RABAs016
Scheme: http
ServerName: 127.0.0.1
ServerPort: 8089
ServletPath: /sv
RequestURL: http://127.0.0.1:8089/mgems/sv/RABAs016

 

你可能感兴趣的:(java,servlet,J2EE,getRequestURL)