1. 程式人生 > >thymeleaf獲取系統根路徑

thymeleaf獲取系統根路徑

path 查看列表 tex pro tco 回首 返回 base mage

  1. 設定根路徑
<head>
    ...
    <!-- 這裏設定了項目根路徑,後面使用到路徑的地方正常填寫即可 -->
    <base th:href="${#request.getContextPath()}+‘/‘">
    ...
</head>

技術分享圖片

  1. 使用,不需要做其他任何設置,正常使用即可
<p><a href="">返回首頁</a><p>
<p><a href="user/list">查看列表</a><p>

技術分享圖片

  1. 實現效果

技術分享圖片

技術分享圖片

thymeleaf獲取系統根路徑