I know this is a duplicate, but I cannot figure this out. I have a file structure like:
How can I link factoid-page.js into factoid-page.html ?
I have tried: <script type="text/javascript" th:src="@{/factoid-page.js}"></script>
This does not work.
Please help, Thanks
CodePudding user response:
Accroading to this page: Add CSS and JS to Thymeleaf
For CSS and JavaScript files, the default directory is src/main/resources/static..
Please reorganize your static
folder:
- put
.js
files into src/main/resources/static/js/ - put
.css
files into src/main/resources/static/css/
and try this
<script type="text/javascript" th:src="@{/js/factoid-page.js}"></script>