request.getURL()和request.getURI() 以及通过request获得路径相关大全

request.getURL()和request.getURI()

  如果我的请求是:http://localhost:8080/ServletTest/servlet/Hello

  request.getRequestURI() 返回值类似:/ServletTest/servlet/Hello

  request.getRequestURL() 返回值类似:http://localhost:8080/ServletTest/servlet/Hello

  再如:

  request.getContextPath() = /ServletTest

  request.getLocalAddr() = 127.0.0.1

  request.getPathInfo() = null

  request.getPathTranslated() = null

  request.getRemoteAddr() = 127.0.0.1

  request.getRequestURI() = /ServletTest/servlet/Hello

  request.getScheme() = http

  request.getServerName() = 127.0.0.1

  request.getServletPath() = /servlet/Hello

  request.getClass() = class ornnector.RequestFacade

  request.getHeaderNames() = org.apache.tomcat.util.http.NamesEnumerator@1fb050c

  request.getLocale() = zh_CN

  request.getLocales() = org.apache.catalina.util.Enumerator@1088a1b

  request.getParameterMap() = {}

  request.getRequestURL() =

  request.getUserPrincipal() = null

  request.getParameterNames() = java.util.Hashtable$EmptyEnumerator@1db6942

  request.getRealPath("newsPub") =

  D:\zfsca\.metadata\.plugins\com.genuitec.eclipse.easie.tomcat.myeclipse\tomcat\webapps\ServletTest\newsPub

  request.getRealPath("/") =

  D:\zfsca\.metadata\.plugins\com.genuitec.eclipse.easie.tomcat.myeclipse\tomcat\webapps\ServletTest\

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