String path = request.getContextPath()和String basePath = request.getScheme()
在JSP当中我们会用此代码来拼接路径,所以此语句是用来拼装当前网页的相对路径的。
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
是用来表明当前页面的相对路径所使用的根路径的。 比如,页面内部有一个连接,完整的路径应该是 http://localhost:8081/cffon/system/login 其中http://server/是服务器的基本路径,myblog是当前应用程序的名字,那么,我的根路径应该是那么http://localhost:8081/cffon/。
request.getSchema()可以返回当前页面使用的协议,就是上面例子中的“http”
request.getServerName()可以返回当前页面所在的服务器的名字,就如同“localhost"
request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是8081,
request.getContextPath()可以返回当前页面所在的应用的名字,就是上面例子中的cffon
这四个拼装起来,就是当前应用的跟路径了
String path = request.getContextPath()和String basePath = request.getScheme()相关推荐
- 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 ...
- String path = request.getContextPath
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+re ...
- basePath = request.getScheme()+://+request.getServerName()+:+r
basePath = request.getScheme()+"://"+request.getServerName()+":"+r (2014-06-30 1 ...
- request.getcontextPath() 详解
<%=request.getContextPath()%>是为了解决相对路径的问题,可返回站点的根路径. 但不用也可以,比如<a href="<%=request.g ...
- request.getContextPath()的功能
<% String contextPath = request.getContextPath(); // 得到项目的名字 com.chint.until.SessionInfo session ...
- Struts2中 Path (getContextPath与basePath)
struts2中的路径问题是根据action的路径而不是jsp路径来确定,所以尽量不要使用相对路径. 虽然可以用redirect方式解决,但redirect方式并非必要. 解决办法非常简单,统一使用绝 ...
- request.getcontextPath() 详解(转)
本文转自:http://blog.csdn.net/pengxuan/article/details/6604578 <%=request.getContextPath()%>是为了解决相 ...
- request.getContextPath详解
<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+ ...
最新文章
- csgo国服文件转国际服务器,csgo国际服怎么转国服 csgo国际服转到国服方法介绍...
- python初学者视频-python从入门到精通视频(全60集)
- 更改微软更新服务器地址,更新服务 | Microsoft Docs
- MDB!= JMS,反之亦然
- ifconfig route 手动设置网卡route路由 示例
- 【extjs6学习笔记】1.9 初始: Mixins
- 网页为什么只加载了基本html,关于HTML的那些事
- 2.10 环境变量PATH 2.11 cp命令 2.12 mv命令 2.13 文档查看cat/mor
- 黑客帝国canvas黑客帝国代码雨特效-A5源码
- qt android编程,Qt for Android开发实例教程
- 照片放大模糊怎么变清晰,图片无损放大
- Java中new Date插入mysql数据库,数据库时间多一秒问题
- 3000商家挤进云栖小镇,抢滩阿里速卖通平台
- 屏蔽html查看源代码,禁止查看网页源代码方法
- 关键字生成参考文案查找相似款,特卖淘宝达人有福了,自媒体时代的懒人助手
- LaTex公式长度过长
- 微信破解WiFi密码如何操作?一招帮你查看密码!
- Typora收费了?推荐两款Markdown编辑器
- php中substr函数用法,关于substr函数的详细介绍
- docker安装后启动失败
热门文章
- Codeforces Round #599 (Div. 2) E. Sum Balance 图转换 + 子集dp + 环
- 【LOJ6033】棋盘游戏【二分图博弈】
- 牛客练习赛75 D 减数游戏(队列优化(需要取模的)堆)
- hdu4609 3-idiots
- P2761 软件补丁问题
- 牛客NOIP2021提高组OI赛前模拟赛第一场T3——与巨(数学)
- CF718E Matvey‘s Birthday(状压、bfs、暴力、分类讨论)
- P3435-[POI2006]OKR-Periods of Words【KMP】
- jzoj1164-求和【欧拉函数,数论】(筛欧拉函数模板)
- POJ2524——宗教(Ubiquitous Religions)【图论,并查集】