%--
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);
%>