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}"
,其中的绝对地址可以换成相对地址。