来源于:http://fanshuyao.iteye.com/blog/2097229
首先了解是什么是<base href="">
<base href="value">为页面上所有相对 URL 规定基准 URL:
- <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>
==========================================================
<base href="http://www.baidu3.com" />
<script type="text/javascript" src="plugins/supersized/supersized.3.2.7.min.js"></script>
<link rel="stylesheet" href="css/login/login.css">
结果:
Request URL:
http://www.baidu3.com/plugins/supersized/supersized.3.2.7.min.js
Request URL:
http://www.baidu3.com/css/login/login.css
相关推荐
<base href="<%=basePath%>"> <title>My JSP 'text.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta ...
<base href="<%=basePath%>"> <title>My JSP 'text1.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta ...
spring 的实例源码 <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> ...
三、实验内容 页面代码:register.jsp <html> <head> <base href="<%=basePath%>"> <title>欢迎注册</title> </head> <body> <center> <form action="register.jsp" method="post"> <h2>用户注册</h2> <table width...
<td><a href='addUser.jsp'>添加</a> <a href='<%=basePath%>DelUserServlet?id=<%=users.getId()%>'>删除</a> <a href='updateUser.jsp'>更新</a> <a href="login.jsp">登陆</...
<base href="<%=basePath%>"> <title>动漫搜索</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> ...
<base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta ...
ajax无刷新来聊天代码 只发关键部分了啊 /* *@ author 让痛苦痛苦 ... <base href="<%=basePath%>"> <% ArrayList al=(ArrayList)new UsersBo().ShowAllUsersZaixian(); %> .............
ajax无刷新聊天代码 只发关键部分了啊 /* *@ author 让痛苦痛苦 *@ param 开源QQ群:... <base href="<%=basePath%>"> <% ArrayList al=(ArrayList)new UsersBo().ShowAllUsersZaixian(); %> .............
%=basePath%>"> <title>My JSP 'CatalogPage.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta ...
<base href="<%=basePath%>"> <title>My JSP 'image.jsp' starting page</title> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <meta ...
%=basePath%>"> <title>票卡类型管理</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <link rel=...
BaseHref="" 相对链接的基地址 ContentLangDirection="ltr/rtl" 默认文字方向 ContextMenu=字符串数组,右键菜单的内容 CustomConfigurationsPath="" 自定义配置文件路径和名称 Debug=true/false 是否开启调试...
%=basePath%>"> <title>My JSP 'Counter.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <...
%=basePath%>">删掉,否则FlexPaper不能浏览文件。 3.FlexPaper不能正常浏览文件的时候,可以试试在官网添加信任。网址...
document.getElementById("isOkMsg").src = "<%=basePath%>/images/nos.png"; document.getElementById("usName").focus(); document.getElementById("login_ok").removeAttribute("disabled"); } function _...
本文实例分析了JSP页面文件中base标记用法。分享给大家供大家参考,具体如下: 我们在用IDE工具生成JSP页面时通常都包含下面的两段代码, <% String path = request.getContextPath(); String basePath = ...
第一次用jsp写东西,在webroot子文件夹下写jsp,当提交到Servlet时报404错误,老以为是子文件的问题,其实不是。...base href=”<%=basePath%>”> 呵呵,这种情况很奇葩吧,对于新手来说简
=basePath%>> <title>My JSP 'ztree.jsp' starting page</title> <link rel=stylesheet href=zTrees/css/zTreeStyle/zTreeStyle.css type=text/css> < script type=text/javascript src=...
% basePath%>"> <title>My JSP "MyJsp jsp" starting page< title> <script type "text javascript" src "<% basePath%>lhgcalendar lhgcore js&...