简体   繁体   中英

Groovy spring boot project with javascript

I am following this guide's structure.

I have added a script.js file (currently placed in the templates directory). This script.js is referenced from one of my html files, however when i start my application the script.js is not being found successfully.

From what i'm seeing i think you need to @Grab it somehow? Not sure.

How can i make it that my script.js file is discoverable?


Edit:

Here is a quicker view of my structure

  • src
    • My.java
  • templates
    • greeting.html
    • script.js
  • app.groovy

greeting.html contains <script src="script.js" /> however it is not being loaded

Per the user guide : if the resource is static you could try putting static content in one of the standard locations (eg classpath:static/ or classpath:public/ ).

If you need it to be a template (not sure thymeleaf can handle that easily) then you would have to change the view resolver configuration, but my guess is that's not the problem.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM