解決springboot使用thymeleaf加載靜態資源訪問路徑問題

1.在所有需要加載靜態資源的頁面加上如下一句話

<!-- 第一種方式:<base> 標籤爲頁面上的所有鏈接規定默認地址或默認目標 -->
<base th:href="@{/}">

2.引用靜態資源的方式

th:href="@{static/assets/css/amazeui.min.css}

3.我的springboot配置

#模板文件位置
spring.thymeleaf.prefix=classpath:/templates/
spring.resources.static-locations=classpath:/static/
spring.mvc.static-path-pattern=/static/**

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章