image - Grails Controller 中的资源路径

标签 image grails resources controller

假设我正在将图像网址列表从服务器传递到前端。

images/
    image1.jpg
    image2.jpg
    image3.jpg

现在,我只是列出文件名,但是我需要引用绝对路径(/application/images/image1.jpg)。基本上相当于${resource}服务器端。

最佳答案

您可以在 Controller 中调用以下代码:

String pathToImage1 = g.resource(dir: 'images', file: 'image1.jpg', absolute: true)

标志“absolute”可能会被跳过。

关于image - Grails Controller 中的资源路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4706945/

相关文章:

c# - WPF/Prism : How to make a resource in my main app trickle down into a usercontrol contained in a separate assembly?

delphi - 在 Delphi 7 中直接从内存加载 DLL

android - 同心旋转叠加图像

css 交换图像大小

wpf - 在 WPF 中裁剪图像

grails - kafka无法连接到远程服务器

image - 使用 Julia 中的图像将 Uint8 数组导出为图像

grails - 覆盖 addTo 和 removeFrom 以监听 Grails 中属性的变化

mysql - 使用 GORM 或 MySql 分组

c++ - 找不到资源断言文件