request.getRequestURI() 返回值类似:/xuejava/requestdemo.jsp
request.getRequestURL() 返回值类似:http://localhost:8080/xuejava/requestdemo.jsp
附:
request.getContextPath() = /hboys request.getLocalAddr() = 127.0.0.1 request.getPathInfo() = null request.getPathTranslated() = null request.getRemoteAddr() = 127.0.0.1 request.getRequestURI() = /hboys/ request.getScheme() = http request.getServerName() = 127.0.0.1 request.getServletPath() = /index.jsp request.getClass() = class org.apache.catalina.connector.RequestFacade request.getHeaderNames() = org.apache.tomcat.util.http.NamesEnumerator@1ad0839 request.getLocale() = zh_CN request.getLocales() = org.apache.catalina.util.Enumerator@f6f1b6 request.getParameterMap() = {} request.getRequestURL() = http://127.0.0.1:8081/hboys/ request.getUserPrincipal() = null request.getParameterNames() = java.util.Hashtable$EmptyEnumerator@1629e71 request.getRealPath("newsPub") = D:\workspace\hboys\WebRoot\newsPub