getContextPath、getServletPath、getRequestURI的区别
来源:互联网 发布:数据建模经典教程 pdf 编辑:程序博客网 时间:2024/05/24 01:44
假定你的工程名称为projects,你在浏览器中输入请求路径:
http://127.0.0.1:8080/projects/pages/newForm.jsp
则执行下面向行代码后打印出如下结果:
1、 System.out.println(request.getContextPath());
打印结果:/projects
2、System.out.println(request.getServletPath());
打印结果:/pages/newForm.jsp
3、 System.out.println(request.getRequestURI());
打印结果:/projects/pages/newForm.jsp
4、 System.out.println(request.getRealPath("/"));
JSP servlet API提供了getRealPath(path)方法,返回给定虚拟路径的真实路径,如果转换错误,则返回null。
打印结果:C:\Tomcat5.0\webapps\projects\test
阅读全文
0 0
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- getContextPath、getServletPath、getRequestURI的区别
- 汉字编码
- CCF Markdown(Java)
- 文章标题
- 4. Median of Two Sorted Arrays
- 第十九课(二) 使用存储过程
- getContextPath、getServletPath、getRequestURI的区别
- 字符界面下,如何配置Linux系统的网络IP地址
- ImportError: cannot import name 'downsample'
- do_brk()剖析
- 如何修改MVC DispatcherServlet配置文件的路径
- Python序列通用操作
- ISBN 号码(201312_2)
- 数据结构-链表-练习题1
- 关于位运算几道经典题目