JSP中<base href="<%=basePath%>">的作用
2014-07-29 17:45
633 查看
JSP中<base href="<%=basePath%>">的作用
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
蕃薯耀 2014年7月28日 11:56:27 星期一
首先了解是什么是<base href="">
<base href="value">为页面上所有相对 URL 规定基准 URL:
Html代码
<head>
<base href="http://www.w3school.com.cn/i/" />
</head>
<body>
<img src="eg_smile.gif" />
</body>
值 描述
Java代码
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
获取当前项目的路径,如:http://localhost:8080/项目名称/。
设置基础路径的,basePath为变量,简单的静态网页的话你设置比如:
<base href="http://www.baidu.com">,那你下面的href属性就会以你上面设的为基准,
如:<a href="http://www.baidu.com/xxx.htm"></a>,你现在就只需要写<a href="xxx.htm"></a>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
蕃薯耀 2014年7月28日 11:56:27 星期一
首先了解是什么是<base href="">
<base href="value">为页面上所有相对 URL 规定基准 URL:
Html代码
<head>
<base href="http://www.w3school.com.cn/i/" />
</head>
<body>
<img src="eg_smile.gif" />
</body>
定义和用法
href 属性规定页面中所有相对链接的基准 URL。语法
<base href="value">
属性值
值 描述URL | 作为基准 URL 的绝对 URL(比如 "http://www.example.com/")。 |
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
获取当前项目的路径,如:http://localhost:8080/项目名称/。
设置基础路径的,basePath为变量,简单的静态网页的话你设置比如:
<base href="http://www.baidu.com">,那你下面的href属性就会以你上面设的为基准,
如:<a href="http://www.baidu.com/xxx.htm"></a>,你现在就只需要写<a href="xxx.htm"></a>
相关文章推荐
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中的 < base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">对相对路径的影响
- JSP中<base href="<%=basePath%>">作用
- 转载:如何理解jsp页面中的“<base href="<%=basePath%>">”?
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">作用
- JSP中<base href="<%=basePath%>">的作用
- JSP中<base href="<%=basePath%>">作用