1. 程式人生 > >關於路徑前面加"/"與不加"/"的區別小記

關於路徑前面加"/"與不加"/"的區別小記

如在jsp頁面引入js時候使用以下兩個路徑:

<script type="text/javascript" src="/js/jquery-3.2.1.js"></script>

<script type="text/javascript" src="js/jquery-3.2.1.js"></script>

比如當前jsp頁面的路徑是http://localhost:8080/demo/page/test.jsp

加"/"代表 絕對路徑,是從站點的根目錄開始找 http://localhost:8080/js/jquery-3.2.1.js

不加"/"代表 相對路徑,是從當前路徑開始找 http://localhost:8080/demo/page/js

/jquery-3.2.1.js