String path = request.getContextPath
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
这个语句是用来拼装当前网页的相对路径的。
<base href="...">是用来表明当前页面的相对路径所使用的根路径的。
比如,页面内部有一个连接,完整的路径应该是 http://localhost:80/myblog/authen/login.do
其中http://server/是服务器的基本路径,myblog是当前应用程序的名字,那么,我的根路径应该是那么http://localhost:80/myblog/。
有了这个 <base ... >以后,我的页面内容的连接,我不想写全路径,我只要写 authen/login.do就可以了。服务器会自动把 <base ...>指定的路径和页面内的相对路径拼装起来,组成完整路径。
如果没有这个 <base...>,那么我页面的连链接就必须写全路径,否则服务器会找不到。
request.getSchema()可以返回当前页面使用的协议,就是上面例子中的“http”
request.getServerName()可以返回当前页面所在的服务器的名字,就是上面例子中的“localhost"
request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是80,
request.getContextPath()可以返回当前页面所在的应用的名字,就是上面例子中的myblog
这四个拼装起来,就是当前应用的跟路径了
String path = request.getContextPath的更多相关文章
- String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";作用!!!!!
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...
- String path = request.getContextPath();这段什么用
<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...
- <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...
- jsp中的<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...
- jsp页面String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";作用!!!!!
转自:https://blog.csdn.net/kiwangruikyo/article/details/81130311 <%String path = request.getContext ...
- 关于String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
关于 String path = request.getContextPath(); String basePath = request.getScheme()+"://"+req ...
- String path = request.getContextPath();报错
String path = request.getContextPath();报错 1. 右击该项目 - Build Path - Configure Build Path , 在 Libraries ...
- request.getcontextPath() 详解
request.getcontextPath() 详解 文章分类:Java编程 <%=request.getContextPath()%>是为了解决相对路径的问题,可返回站点的根路径. 但 ...
- request.getContextPath获取绝对路径
request.getContextPath获取绝对路径 博客分类: 经验+注意 其他 request.getContextPath 项目需求:所有jsp页必须通过Action转发,不能直接在地址栏链 ...
随机推荐
- Linux服务器快速安装可视化桌面且可以远程RDP远程连接
我们很多网友在选择Linux服务器的时候并不是用来做网站的,有些是需要用到远程桌面安装软件或者是其他用途.但是我们知道大部分海外主机商是只有LINUX系统且没有可视化桌面,当然也有一些商家是支持安装G ...
- 关于component-scan中base-package包含通配符的问题探究
http://blog.csdn.net/u012325167/article/details/75388990 今天在配置Spring的component-scan时,发现了一个有趣的问题.就是在指 ...
- 现代cpu的合并写技术对程序的影响
对于现代cpu而言,性能瓶颈则是对于内存的访问.cpu的速度往往都比主存的高至少两个数量级.因此cpu都引入了L1_cache与L2_cache,更加高端的cpu还加入了L3_cache.很显然,这个 ...
- 【转】使用SQL Server 2012的FileTable轻松管理文件
一 .FileStream和FileTable介绍 我们经常需要把结构化数据(int.Char等)和非结构化数据(如Varbinary(max))一起存储,那我们在怎么存储的呢? 1. 在SQL Se ...
- Notepad++软件的下载与安装步骤(图文详解)
不多说,直接上干货! 这款软件非常好用!!! 1.下载Notepad++软件 Notepad++非常好用,想要安装首先我们要下载(废话)~ 百度搜索“Notepad++”直接就可以找到主页: 主页 ...
- window启动程控制
1.启动服务管理(RPC) 2.开启远程选项 3.开启防火墙允许
- ActiveMQ发布-订阅消息模式
一.订阅杂志我们很多人都订过杂志,其过程很简单.只要告诉邮局我们所要订的杂志名.投递的地址,付了钱就OK.出版社定期会将出版的杂志交给邮局,邮局会根据订阅的列表,将杂志送达消费者手中.这样我们就可以看 ...
- WPF在XAML的资源中定义空字符串String.Empty
代码如下: <!--1. 首先引用System的命名空间--> <Window x:Class="DriverEasyWPF.Views.DialogWindow" ...
- BSDL
BSDL(边界扫描描述语言)文件是使用边界扫描进行电路板级和系统级测试与在系统编程所必需的. BSDL 文件是描述一个 IC 中的 IEEE 1149.1 或 JTAG 设计电子数据表,这些文件由 I ...
- BI实战派:医疗BI项目落地方案
任何BI项目面临的两大难题是项目价值和基础数据,BI项目应该给企业带来管理优化.业绩增长.医院面临的两大难题,一:绩效管理(奖金分配):二:医患关系:在医院开始自负盈亏时日常基本运营管理显得非常重要. ...