Web应用中request获取各种获取path或URI,URL的方法

Web应用中有各种获取path或URI,URL的方法,假设网页访问地址:

http://localhost:8080/tradeload/TestServlet

Web应用context: /tradeload 

各路径鉴定如下:

request.getContextPath()= /tradeload
request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()= http://localhost:8080
request.getRequestURL() = http://localhost:8080/tradeload/TestServlet
request.getRequestURI() = /tradeload/TestServlet
request.getPathInfo() = null
request.getServletPath() = /TestServlet
getServletContext().getRealPath('/') = C:\server\glassfish\domains\domain1\applications\j2ee-modules\tradeload\

 

原文出处:http://improve.iteye.com/blog/741427

 

posted @ 2016-07-10 08:04  cl00032  阅读(937)  评论(0编辑  收藏  举报