basePath
来源:互联网 发布:华为数据 编辑:程序博客网 时间:2024/06/15 01:09
myeclipse新建jsp文件时在顶部会自动生成这些代码
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
在里写上<base href="<%=basePath%>">
这说明在该页面中的所有路径都是于项目的WebRoot为相对路径,如项目的WebRoot下的Images/xxx.jpg,则在任何含有<base href="<%=basePath%>">
的页面中都是以Images/xxx.jpg来访问该图片。
例如
WebRoot/jsp/first.jsp
在first.jsp中含有xxx.jpg应该为<img src="Images/xxx.jpg"/>
而不是<img src="../Images/xxx.jpg"/>
好处:
1.不需要在页面中以../或../../来回到上级或上上级目录
2.都是相对于WebRoot目录,实现了路径的统一
0 0
- basePath
- basePath
- basePath
- basePath
- basepath 变量
- 关于BasePath
- JSP BASEPATH
- 页面路径 basepath
- String basePath 相关解释
- JSP里的basePath
- basepath的作用
- basepath的作用
- 关于jsp的basepath
- String path 、String basePath
- basePath 的使用
- 02-JavaScript获取BasePath
- jsp中的basePath
- basepath的作用
- 浅谈矩阵分解在推荐系统中的应用
- MATLAB中MEX文件的编写与调试
- android studio创建aidl文件
- 在Interface Builder中有效地工作的8个技巧
- HC-05蓝牙配置
- basePath
- C#静态构造函数
- (一)RxJava在Android网络框架中的使用
- php 读正在写的文件
- Unicode编码转换最简单方法
- Leetcode 100. Same Tree
- CSS、JS 放置位置与前端性能的关系?
- Mysql 的日期类型:DATETIME和TIMESTAMP
- WebSocket与STOMP介绍