如何从模板 html 页面中访问 JS 文件? Spring开机
How to access JS file from within template html page? Spring Boot
我知道这是重复的,但我无法弄清楚。
我的文件结构如下:
我怎样才能link factoid-page.js变成factoid-page.html?
我试过了:<script type="text/javascript" th:src="@{/factoid-page.js}"></script>
这不起作用。
请帮忙,谢谢
访问此页面:Add CSS and JS to Thymeleaf
For CSS and JavaScript files, the default directory is src/main/resources/static..
请重新整理您的 static
文件夹:
- 将
.js
个文件放入src/main/resources/static/js/
- 将
.css
个文件放入src/main/resources/static/css/
试试这个
<script type="text/javascript" th:src="@{/js/factoid-page.js}"></script>
我知道这是重复的,但我无法弄清楚。
我的文件结构如下:
我怎样才能link factoid-page.js变成factoid-page.html?
我试过了:<script type="text/javascript" th:src="@{/factoid-page.js}"></script>
这不起作用。
请帮忙,谢谢
访问此页面:Add CSS and JS to Thymeleaf
For CSS and JavaScript files, the default directory is src/main/resources/static..
请重新整理您的 static
文件夹:
- 将
.js
个文件放入src/main/resources/static/js/ - 将
.css
个文件放入src/main/resources/static/css/
试试这个
<script type="text/javascript" th:src="@{/js/factoid-page.js}"></script>