">
2010-07-05 13:31
155 查看
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1107304683 0 0 159 0;}
@font-face
{font-family:simsun;
panose-1:0 0 0 0 0 0 0 0 0 0;
mso-font-alt:"Times New Roman";
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-format:other;
mso-font-pitch:auto;
mso-font-signature:0 0 0 0 0 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman","serif";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
font-size:10.0pt;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;
mso-ascii-font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-hansi-font-family:"Times New Roman";
mso-font-kerning:0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
base
标记是一个基链接标记,是一个单标记。用以改变文件中所有连结标记的参数内定值。它只能应用于标记
<head>
与
</head>
之间。
你网页上的所有相对路径在链接时都将在前面加上基链接指向的地址。
base
元素可规定页面中所有链接的基准
URL
我们可以使用
<base>
标签中的
href
属性来设置,所有的
“
相对基准
URL”
。
这是
JSP
端的代码
采用了
html
文件中的
<base>
标签:
代码如下
:
<%
String path = request.getContextPath();
//
获得项目完全路径(假设你的项目叫
myWork
,那么获得到的地址就是 http://localhost:8080/myWork/
)
:
String basePath =
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//
将
"
项目路径
basePath"
放入
pageContext
中
%>
<html>
<head>
<base href=" <%=basePath%>">
//base
只能应用于标记
<head>
与
</head>
之间
</head>
//
这里我们就可以直接使用相对路径
(
即
:
相对于
base
标签
)
<a href="jsp/login.jsp">Login </a>
</html>
当我们去执行上面的那段
JSP
代码后,我们可以在浏览器中可以查看,他所返回给客户端的
html
代码
:
执行完上述
JSP
后,所返回的
html
代码如下
:
<html>
<head>
<base href="http://localhost:8080/myWork/
">
</head>
//
设置了
<base>
后,相对路径,相对于的就是
base
中的路径,而不再是浏览器地址的请求路径啦
~~~
<a href="jsp/login.jsp">Login </a>
</html>
我们可以看到
JSP
返回的
html
代码中,包含了
<base href="http://localhost:8080/myWork/
">
内容。
也就是说,在本
html
文件中,遇到的所有
“
相对链接
(
例如
: <a href="jsp/login.jsp">)”
,都是相对于
base
的路径
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1107304683 0 0 159 0;}
@font-face
{font-family:simsun;
panose-1:0 0 0 0 0 0 0 0 0 0;
mso-font-alt:"Times New Roman";
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-format:other;
mso-font-pitch:auto;
mso-font-signature:0 0 0 0 0 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman","serif";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
font-size:10.0pt;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;
mso-ascii-font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-hansi-font-family:"Times New Roman";
mso-font-kerning:0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
base
标记是一个基链接标记,是一个单标记。用以改变文件中所有连结标记的参数内定值。它只能应用于标记
<head>
与
</head>
之间。
你网页上的所有相对路径在链接时都将在前面加上基链接指向的地址。
base
元素可规定页面中所有链接的基准
URL
我们可以使用
<base>
标签中的
href
属性来设置,所有的
“
相对基准
URL”
。
这是
JSP
端的代码
采用了
html
文件中的
<base>
标签:
代码如下
:
<%
String path = request.getContextPath();
//
获得项目完全路径(假设你的项目叫
myWork
,那么获得到的地址就是 http://localhost:8080/myWork/
)
:
String basePath =
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//
将
"
项目路径
basePath"
放入
pageContext
中
%>
<html>
<head>
<base href=" <%=basePath%>">
//base
只能应用于标记
<head>
与
</head>
之间
</head>
//
这里我们就可以直接使用相对路径
(
即
:
相对于
base
标签
)
<a href="jsp/login.jsp">Login </a>
</html>
当我们去执行上面的那段
JSP
代码后,我们可以在浏览器中可以查看,他所返回给客户端的
html
代码
:
执行完上述
JSP
后,所返回的
html
代码如下
:
<html>
<head>
<base href="http://localhost:8080/myWork/
">
</head>
//
设置了
<base>
后,相对路径,相对于的就是
base
中的路径,而不再是浏览器地址的请求路径啦
~~~
<a href="jsp/login.jsp">Login </a>
</html>
我们可以看到
JSP
返回的
html
代码中,包含了
<base href="http://localhost:8080/myWork/
">
内容。
也就是说,在本
html
文件中,遇到的所有
“
相对链接
(
例如
: <a href="jsp/login.jsp">)”
,都是相对于
base
的路径
相关文章推荐
-  |"|&|<|>等html字符转义
- asp.net/c# 用<input type="file" />实现文件上传,multipart/form-data
- <script language= "javascript " for= "window " event= "onload " /> 的问题解读
- <authentication mode="Forms"> 发布错误
- 使用<base target="_self" /> IE6 cann't open the Internet site 已终止操作
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />详解
- <jsp:directive.page import=""/>的用法和解释
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <jsp:directive.page import=""/> 和<%@ page import="" %>的区别
-  |"|&|<|>等html字符转义
-  |"|&|<|>等html字符转义
- <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>解释
- "<br />"和 "\r\n" 这两者有什么区别??
- <context:property-placeholder location="classpath:com/foo/jdbc.properties"/>、元数据与一个定制配置BeanFactoryPo
- <c:set var="root" value="${pageContext.request.contextPath}"></c:set>According to TLD or attribute d
- Hibernate实体类映射文件demo.hbm.xml 中的<generator class="?"></generator>的不同属性含义
- <form action="get.php" method="post" id="tform"> <input type="text" name="one"> <a href="jav
- <form>标签只能作用一个<input type="hidden"/>?
- <category android:name="android.intent.category.DEFAULT" /> 惹的祸