为页面上所有相对 URL 规定基准 URL

<%
     String path = request.getContextPath();
     String basePath = request.getScheme() + "://" + request.getServerName()
                    + ":" + request.getServerPort() + path + "/";
%>
   <%--告诉服务器,当前JSP的路径定位发哦基本路径,JSP中的所有静态文件x.js ,等等。
        获取是都以该为基准路径--%>
   <base href="<%=basePath%>">
原文地址:https://www.cnblogs.com/monster-jian/p/13540567.html