用户名: 密   码:
   飞诺网 加入收藏
飞诺网 网页设计 FrontPage Dreamweaver html Javascript css 网页制作技巧 网页特效 色彩原理 设计理念 web技术文档
FrontPage Dreamweaver html Javascript css 网页制作技巧 网页特效 色彩原理 设计理念 web技术文档

您当前的位置:飞诺网 >>  网页设计 >> web技术文档

Request中getContextPath、getServletPath、getRequestURI、request.getRealPath的区别

www.diybl.com    时间 : 2008-09-17  作者:佚名   编辑:辉辉 点击:   [ 评论 ]

假定你的web application 名称为news,你在浏览器中输入请求路径:

http://localhost:8080/news/main/list.jsp

则执行下面向行代码后打印出如下结果:

1、 System.out.println(request.getContextPath());

打印结果:/news
  2、System.out.println(request.getServletPath());

打印结果:/main/list.jsp
 3、 System.out.println(request.getRequestURI());

打印结果:/news/main/list.jsp
 4、 System.out.println(request.getRealPath("/"));
 

打印结果:F:\Tomcat 6.0\webapps\news\test

想不清楚的代码或原理,动手试验一般会找到答案!!!



如果图片或页面不能正常显示请点击这里
web技术文档推荐文章

文章评论