JSP中<base href="<%=basePath%>">的作用
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
首先了解是什么是<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="<%=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>MyJSP 'test.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"> ...
<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 ...
<base href="<%=basePath%>"> <title>主页面</title> </head> <body> <div align="center"> <table> <tr> <th>主页面</th> </tr> </table> </div> <jsp:include page="4-3.jsp"> <jsp:param value="John...
<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"> ...
<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>Login Page</title> <!-- Meta tags for SEO --> ... </head> <body> <% if (username != null) { %> 用户名: <%= username %> <br/> <% } %> <!-- Display the form ...
<link href="<%=basePath %>css/base.css" rel="stylesheet" type="text/css"> <link href="<%=basePath %>css/reg.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="<%=basePath %>css/...
<base href="<%=basePath%>"> <title>MyJSP 'index.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 'userRegister.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta ...
<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 ...
<base href="<%=basePath%>"> <title>MyJSP 'insdata.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta ...
<base href="<%=basePath%>"> <title>MyJSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta ...
<base href="<%=basePath%>"> <title>中国证券会证券期货违法违规举报中心-注册</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta ...
<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%>">`用于设置基础URL路径,方便页面中的链接能够正确指向服务器上的资源。 ##### 2. 用户名和密码输入 HTML部分包含了一个简单的表单,用于收集用户的用户名和密码: ```html <form ...
<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"> <meta ...