The problem is that the script does not connect to my html page. I use Spring boot 1.5.10

Project window:

Project window

Content index.html:

<!DOCTYPE HTML> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> </head> <body> <p>Начало документа</p> <p>Конец документа</p> </body> <script src="../public/js/script.js"></script> </html> 

I tried to replace src = "../ public / js / index.js" with th: src = "@ {../ public / js / index.js} , but still the script is not executed.

index.js contains an alert ('JS подключен и отлично работает!');

The browser complains about GET http://localhost:8080/public/script.js net::ERR_ABORTED enter image description here

I tried to upload the script.js file to the templates folder, specify src="script.js" or src="/script.js" , but still the error is the same.

How to solve this problem?

  • Do not pay attention to the fact that the script in one place is called "script.js", and in the other place is called "index.js", as well as the path to the file. Screenshots and code were taken at different times. In fact, the names are the same there. Already tortured to test, threw in all the folders. - Crunk
  • Maybe I don’t understand something, but you don’t have the path /public/js/script.js . But there is a path /public.js/script.js - Stepan Kasyanenko
  • in the /public.js/script.js = /public/js/script.js file structure. Idea is the name for the folder within which one folder is Crunk
  • And you look out the directory - there should be compiled files for ideas. And you will see on what path there are scripts. - Stepan Kasyanenko
  • one
    and put * .js in the js folder that about html can not be? - batman

0