如何区分:Request中getContextPath、getServletPath、getRequestURI、request.getRealPath
2016-04-24 14:54
429 查看
假定你的web application 名称为Web_day19,
你在浏览器中输入请求路径:http://localhost:8184/Web_day19/userServlet?method=getUser
System.out.println("request.getContextPath() : "+request.getContextPath() );
打印结果:request.getContextPath() : /Web_day19
System.out.println("request.getServletPath() : " + request.getServletPath());
打印结果:request.get[b]ServletPath()
: /userServlet[/b]
System.out.println(" request.getRequestURI() : " + request.getRequestURI() );
打印结果:request.getRequestURI()
: /Web_day19/userServlet
System.out.println("request.getRealPath("/") : "+ request.getRealPath("/") );
打印结果:
request.getRealPath("/") : D:\javastudy\javaWeb\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Web_day19\
你在浏览器中输入请求路径:http://localhost:8184/Web_day19/userServlet?method=getUser
System.out.println("request.getContextPath() : "+request.getContextPath() );
打印结果:request.getContextPath() : /Web_day19
System.out.println("request.getServletPath() : " + request.getServletPath());
打印结果:request.get[b]ServletPath()
: /userServlet[/b]
System.out.println(" request.getRequestURI() : " + request.getRequestURI() );
打印结果:request.getRequestURI()
: /Web_day19/userServlet
System.out.println("request.getRealPath("/") : "+ request.getRealPath("/") );
打印结果:
request.getRealPath("/") : D:\javastudy\javaWeb\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Web_day19\
相关文章推荐
- Adobe系列软件破解on mac-Adobe flash builder on mac
- Stringbuffer和Stringbuilder
- 【Arduino官方教程第一辑】示例程序 2-6 音乐键盘-tone函数的运用
- 人机交互设计——评价谷歌拼音输入法(安卓版)
- BZOJ 1670: [Usaco2006 Oct]Building the Moat护城河的挖掘|二维凸包
- AI中基本工具介绍太原UI设计师分享给你【平面设计、logo设计】
- flash builder 4.7破解亲测可用
- C# 使用Guid类生成不重复的随机数
- POJ:3061 Subsequence(尺取法)
- 按钮UIBUtton的常用属性及方法总结
- MyStringBuild
- hdu 5667 Sequence 矩阵快速幂+费马小定理
- 蘑菇阵(动态规划、百度)——unique paths
- ZOJ 3940 Modulo Query
- POJ 3061 Subsequence(尺取法)
- 人机交互设计之百度搜索软件评价
- The Product Managers’ Guide to Continuous Delivery and DevOps
- UML建模之时序图(Sequence Diagram)
- pcduino与Arduino串口通信
- STL源码笔记(12)—序列式容器之deque(二)