I am trying to link a js (the js is a local file in the project) to this html (results.html) :
The problem is that the js is not loading .
I have try with :
/static/js/ResultspieChart.js
../static/js/ResultspieChart.js
static/js/ResultspieChart.js
But if I use:
<script th:src="@{/js/ResultspieChart.js}"></script>
it works , th is a Java template engine
In fact the url according to intelliJ helper is well formed,where is the problem ?
The file system paths are not resolved correctly most of the times. Use an http server to serve your html and ../static/js/ResultpieChart.js
should work. You can use http-server
npm package as below (Prerequisite: You should have node installed): 1. Install http-server
globally
npm install -g http-server
http-server
in the root of your project http-server
This will start a server at default port (8080). So if you browse localhost:8080
, you can see your files
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.