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()
在JSP当中我们会用此代码来拼接路径,所以此语句是用来拼装当前网页的相对路径的. <% String path = request.getContextPath(); String basePa ...
- jsp中String path = request.getContextPath()的作用
<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...
- String path = request.getContextPath(....拼装当前网页的相对路径
原文地址 <% String path = request.getContextPath(); String basePath = request.getScheme()+"://&q ...
- request.getContextPath()的功能
<% String contextPath = request.getContextPath(); // 得到项目的名字 com.chint.until.SessionInfo session ...
- request.getContextPath详解
<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...
- request.getcontextPath() 详解
<%=request.getContextPath()%>是为了解决相对路径的问题,可返回站点的根路径. 但不用也可以,比如<a href="<%=request.g ...
- Struts2中 Path (getContextPath与basePath)
struts2中的路径问题是根据action的路径而不是jsp路径来确定,所以尽量不要使用相对路径. 虽然可以用redirect方式解决,但redirect方式并非必要. 解决办法非常简单,统一使用绝 ...
- request.getcontextPath() 详解(转)
本文转自:http://blog.csdn.net/pengxuan/article/details/6604578 <%=request.getContextPath()%>是为了解决相 ...
- new File(String Path)加载资源问题
2017-12-17 15:07:38 [原创-wx] 一.我们在用IO流加载资源的时候,创建文件资源 1 File file = New File("String Path" ...
最新文章
- iOS提示气泡,带动画
- 到时间就站起来!用树莓派爆改升降办公桌,懒癌有救了
- 【知识便利贴】ImageNet得的比Best Paper还牛的Longuet-Higgins奖是什么?
- Java-Map从入门到性能分析1【Map初识、Map通用方法、HashMap的使用(遍历方法、性能分析)】
- hyperworks安装教程linux,HyperWorks安装说明.ppt
- 创业者如何防止合伙股东退出,给公司造成损失?
- loop one image for 10 secs
- spring framwork解析
- invalid cookie header httpclient
- C语言进制转换 十进制转换为任意进制
- 密码爆破 hashcat+rar2john破解rar5压缩包密码
- ssh-hostbased配置方法
- 升级Unity2018.3.2f1出现PrecompiledAssemblyException: Multiple precompiled assemblies with the same name
- 微软正式宣布 Visual Studio 2022!
- 网页嵌入Twitter的推文
- python查找文件并重命名_python复制文件并重命名
- 定义一个数组,里面存放星期一、星期二…… 直到星期日(共7天),在页面显示奇数日,如星期一,星期三,星期日等。
- linux扩容VBoxManage
- 对于尺度与分辨率的理解
- (ROSEMOUNT)罗斯蒙特温度变送器
热门文章
- TensorFlow 1.11.0正式版发布了,强力支持Keras
- 内含福利 | 我们“偷”来了一座航站楼。9.21, HAY!18等你来候机!
- 四年一度的菲尔兹奖揭晓,4位数学家折桂
- 马库斯再谈AlphaGo Zero不是从零开始,AGI可能需要这十大先天机制
- 在终端设备上实现语音识别:ARM开源了TensorFlow预训练模型
- 学习python的第五天
- 示范NTFS 卷上的流
- properties配置文件在idea中默认utf-8编码可能会乱码的解决
- 模拟jQuery,简单仿写API
- CHIL-SQL-FOREIGN KEY 约束