base标签的作用

base标签可以自定义当前页面的相对路径,不受浏览器当前地址栏的影响,以base标签定义的地址为准

(只对相对路径起作用)

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--base标签只对相对路径起作用-->
    <base href="http://localhost:8080/Servlet/first/second/">
</head>
<body>

      <!--请求地址为:http://localhost:8080/Servlet/first/second/index.jsp-->
    相对路径:<a href="index.jsp">返回首页</a><br>

      <!--请求地址为:http://localhost:8080/Servlet/index.jsp-->
    相对路径:<a href="../../index.jsp">返回首页</a><br>

      <!--请求地址为:http://localhost:8080/index.jsp-->
    绝对路径:<a href="/index.jsp">返回首页</a><br>
</body>
原文地址:https://www.cnblogs.com/shmebluk/p/13450077.html