标签:translate targe .com system local roo std cto nec
引于: http://hi.baidu.com/cloudxpc
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() =
request.getLocale() = zh_CN
request.getLocales() =
request.getParameterMap() = {}
request.getRequestURL() = http://127.0.0.1:8081/hboys/
request.getUserPrincipal() = null
request.getParameterNames() =
request.getRealPath("newsPub") = D:\workspace\hboys\WebRoot\newsPub
假定你的web application 名称为news,你在浏览器中输入请求路径:
http://localhost:8080/news/main/list.jsp
则执行下面向行代码后打印出如下结果:
1、 System.out.println(request.getContextPath());
打印结果:/news
2、System.out.println(request.getServletPath());
打印结果:/main/list.jsp
3、 System.out.println(request.getRequestURI());
打印结果:/news/main/list.jsp
4、 System.out.println(request.getRealPath("/"));
打印结果:F:\Tomcat 6.0\webapps\news\test
getRequestURI()与getRequestURL()的区别
标签:translate targe .com system local roo std cto nec
原文地址:http://www.cnblogs.com/genhao/p/6814969.html