解决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/**

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