頁面中向服務器頁面請求靜態資源且沒有指定<base href="<%=basePath%>">
訪問以下頁面
localhost:8080/resolvent/index.jsp
localhost:8080/resolvent/servlet/dnf
有/的
跟目錄是域名+端口號(localhost:8080)
請求以下資源
<script type="text/css" src=''/demo.js"></script>
最終浏覽器發送的請求都是localhost:8080/demo.js
沒有/
<script type="text/css" src=''demo.js"></script>
localhost:8080/resolvent/demo.js 當前目錄localhost:8080/resolvent/
localhost:8080/resolvent/servlet/demo.js 當前目錄 localhost:8080/resolvent/servlet/
請求轉發,請求重定向,已以下兩個url為例
localhost:8080/resolvent/servlet/dnf
localhost:8080/resolvent/index.jsp
有/的
根目錄是(localhost:8080/resolvent)
request.getRequestDispatcher("/login.jsp").forward(request,response);
最後都會定位到
localhost:8080/resolvent/login.jsp
沒有/
request.getRequestDispatcher("login.jsp").forward(request,response);
localhost:8080/resolvent/servlet/login.jsp 當前目錄localhost:8080/resolvent/servlet/
localhost:8080/resolvent/login.jsp 當前目錄localhost:8080/resolvent/