springboot+thymeleaf 訪問靜態資源解決(static)


---------------------------------------2.1.3------------------------------------------------------------------

第一步:pom.xml-必須有這個

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

第二步:application.properties

spring.mvc.static-path-pattern=/static/**


訪問js路徑就是:

http://localhost:8081/static/js/jquery.min.js

界面html里面引用路徑
<script src="/static/js/jquery.min.js"></script>

-----------------------------原來我用的是2.1.3 改成 2.0.2一切都解決了(/static/也不用加了)-----------------------------------------------
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM