getContextPath、getServletPath、getRequestURI、request.getRealPath的区别
1 区别
假定你的web application 名称为news,你在浏览器中输入请求路径:
http://localhost:8080/news/main/list.jsp
1.1 System.out.println(request.getContextPath());
打印结果:/news
1.2 System.out.println(request.getServletPath());
打印结果:/main/list.jsp
1.3 System.out.println(request.getRequestURI());
打印结果:/news/main/list.jsp
1.4 System.out.println(request.getRealPath("/"));
打印结果:F:\Tomcat 6.0\webapps\news\test
转自:http://blog.csdn.net/huang_xw/article/details/8008418
${pageContext.request.contextPath}是JSP取得绝对路径的方法,等价于<%=request.getContextPath()%> 。
getContextPath、getServletPath、getRequestURI、request.getRealPath的区别的更多相关文章
- Request中getContextPath、getServletPath、getRequestURI、request.getRealPath的区别
1 区别 假定你的web application 名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 1.1 System.o ...
- request的getServletPath(),getContextPath(),getRequestURI(),getRealPath("/")区别
假定你的web application 名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 则执行下面向行代码后打印出如下结果 ...
- getContextPath、getServletPath、getRequestURI,getRealPath的区别
假定你的web application 项目名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 则执行下面向行代码后打印出如下 ...
- Servlet的getContextPath(), getServletPath(), getRequestURI(), getRealPath("/")
假定web application 名称为news,你在浏览器中输入请求路径: http://localhost:8080/news/main/list.jsp 则执行下面向行代码后打印出如下结果: ...
- getContextPath、getServletPath、getRequestURI、getRealPath、getRequestURL、getPathInfo();的区别
<% out.println("getContextPath: "+request.getContextPath()+"<br/>"); ou ...
- (转)关于request.getServletPath(),request.getContextPath()的总结
文章完全转载自 : https://blog.csdn.net/qq_27770257/article/details/79438987 最近对于request中的几种“路径”有点混淆,查找网上资源都 ...
- 关于J2EE里面getContextPath()和getRealPath()的区别
一直老搞不清楚这两个方法的区别,只知道他们都是拿来获取地址的.今天特意写了个小demo试了一下,代码如下: @Override protected void service(HttpServletRe ...
- getContextPath和getRealPath的区别-----其实主要区别就是相对路径和绝对路径
getContextPath和getRealPath的区别 其实主要区别就是相对路径和绝对路径 https://blog.csdn.net/zsmj_2011/article/details/4121 ...
- getRequestURI()与getRequestURL()的区别
引于: http://hi.baidu.com/cloudxpc request.getRequestURI() 返回值类似:/xuejava/requestdemo.jsprequest.getRe ...
随机推荐
- 第四篇:MapReduce计算模型
前言 本文讲解Hadoop中的编程及计算模型MapReduce,并将给出在MapReduce模型下编程的基本套路. 模型架构 在Hadoop中,用于执行计算任务(MapReduce任务)的机器有两个角 ...
- 简单mysql类
---恢复内容开始--- class mysql { private $host; private $user; private $pass; private $database; private $ ...
- 【MATLAB】评价二值分割结果的函数
根据PASCAL challenges的标准:intersection-over-union score,所写的matlab评价程序,处理二值图像. 其思想即分割结果与Ground Trueth的交集 ...
- jquery.sparkline.js简介
jQuery线状图插件Sparkline 官网地址:http://omnipotent.net/jquery.sparkline/ 文档地址:http://omnipotent.net/jquery. ...
- spring cache 详解
Spring使用Cache 从3.1开始,Spring引入了对Cache的支持.其使用方法和原理都类似于Spring对事务管理的支持.Spring Cache是作用在方法上的,其核心思想是这样的:当我 ...
- |和||、&&和&
|和||.&&和& | : 会检查每一个 条件的真伪,再做“或”运算 ||: 按照条件写的顺序,直到一个为true时,后面的条件则不再检查,直接进入条件 & : 会检查 ...
- 正则表达式取querystring
var s = decodeURIComponent((new RegExp('[?|&]userid=([^&;]+?)(&|#|;|$)').exec(location.h ...
- sencha touch 2.3.1 list emptyText不显示
如图所示,有时候没有取到任何的数据. 那么我们就需要显示没有获取到内容这一类提示,显示内容通常通过emptyText这个属性来配置. 但是在sencha touch 2.3.1之中有可能会出问题,所以 ...
- 一键用VS编译脚本
set MSBUILD_PATH="C:\Program Files (x86)\MSBuild\12.0\Bin\MsBuild.exe" set ZIP_TOOL=" ...
- JDBC的驱动是如何加载的
注:本文出处:http://www.cnblogs.com/jiaoyiping/ 转载请保留出处 JDBC定义了一套接口,数据库产品的提供商会实现这些接口来提供自己的数据库驱动程序,这是个很好的面向 ...