码迷,mamicode.com
首页 > 编程语言 > 详细

java中通过request获取路径中的不同信息

时间:2014-11-05 13:06:11      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:style   http   color   os   java   sp   文件   on   size   

aa为工程中的项目名

bb为webRoot下的文件夹

1、request.getContextPath(); 输出结果:/aa

2、request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path; 输出结果:http://localhost:8080/aa

3、request.getServletPath();(获取客户端请求文件的路径)输出结果:/bb/content/contentList.jsp

4、request.getRequestURI();(获取发出请求字符串的客户端地址,得到的是requestURL的部分值,并且web容器没有decode过的)输出结果:/aa/bb/content/contentList.jsp

5、request.getRequestURL();(返回请求全部,包括http协议,servlet名字,端口号,映射路径,但不包含请求参数,)输出结果:http://localhost:8080/aa/bb/content/contentList.jsp


java中通过request获取路径中的不同信息

标签:style   http   color   os   java   sp   文件   on   size   

原文地址:http://blog.csdn.net/lv_shijun/article/details/40819859

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!