Spring Boot 引入外部js到项目不能调用的问题

html板在templates下面,js文件在static下面,在模板中引用时不需要加static这个路径。

例如:


src
  └─main
     ├─java
     └─resources
         ├─static
         │  ├─css
         │  ├─img
         │  └─js
         │    └─test.js
         └─templates


在模板中引用test.js, 你引用的地址应当为/js/test.js,换成thymeleaf的属性则应当为th:src="@{/js/test.js}",其中的绝对地址可以换成相对地址。


猜你喜欢

转载自blog.csdn.net/DreamWeaver_zhou/article/details/80089122