You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
BookStore/web/pages/common/header.jsp

33 lines
1.1 KiB

3 years ago
<%--
Created by IntelliJ IDEA.
User: jhu
Date: 2020/10/5
Time: 11:06
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
4 weeks ago
// 获取当前请求的协议如http或https
String scheme = request.getScheme();
// 获取服务器的主机名或IP地址
String serverName = request.getServerName();
// 获取服务器的端口号
int serverPort = request.getServerPort();
// 获取当前应用的上下文路径
String contextPath = request.getContextPath();
3 years ago
4 weeks ago
// 拼接basePath用于构建项目的根路径
String basePath = scheme + "://" + serverName + ":" + serverPort + contextPath + "/";
// 将basePath存储到pageContext中方便在页面中使用
pageContext.setAttribute("basePath", basePath);
3 years ago
%>
4 weeks ago
3 years ago
<!-- 写base标签永远固定相对路径跳转的结果 -->
4 weeks ago
<base href="<%=basePath%>">
<!-- 引入外部的CSS样式文件 -->
<link type="text/css" rel="stylesheet" href="static/css/style.css">
<!-- 引入外部的jQuery库 -->
<script type="text/javascript" src="static/script/jquery-1.7.2.js"></script>