首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

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

2012-10-31 
Web应用中request获取各种获取path或URI,URL的方法Web应用中有各种获取path或URI,URL的方法,假设网页访问

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\ 

?
其中的servletpath就是web.xml中配置的url-pattern。

?

?

热点排行