简体   繁体   English

使用JavaScript的Groovy Spring Boot项目

[英]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). 我添加了一个script.js文件(当前位于模板目录中)。 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. 这个script.js是从我的html文件之一引用的,但是当我启动我的应用程序时,并未成功找到script.js。

From what i'm seeing i think you need to @Grab it somehow? 从我所见,我认为您需要以某种方式@Grab? Not sure. 不确定。

How can i make it that my script.js file is discoverable? 如何确定我的script.js文件可被发现?


Edit: 编辑:

Here is a quicker view of my structure 这是我的结构的快速视图

  • src src
    • My.java 我的java
  • templates 范本
    • greeting.html greeting.html
    • script.js script.js
  • app.groovy 应用程序

greeting.html contains <script src="script.js" /> however it is not being loaded greeting.html包含<script src="script.js" />但尚未加载

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/ ). 根据用户指南 :如果资源是静态的,则可以尝试将静态内容放入标准位置之一(例如classpath:static/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. 如果您需要将其用作模板(不确定百里香叶是否可以轻松处理),则必须更改视图解析器配置,但是我想这不是问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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