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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<%--
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" %>
<%
// 获取当前请求的协议如http或https
String scheme = request.getScheme();
// 获取服务器的主机名或IP地址
String serverName = request.getServerName();
// 获取服务器的端口号
int serverPort = request.getServerPort();
// 获取当前应用的上下文路径
String contextPath = request.getContextPath();
// 拼接basePath用于构建项目的根路径
String basePath = scheme + "://" + serverName + ":" + serverPort + contextPath + "/";
// 将basePath存储到pageContext中方便在页面中使用
pageContext.setAttribute("basePath", basePath);
%>
<!-- 写base标签永远固定相对路径跳转的结果 -->
<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>