部署在 tomcat 服务器中时从 grails 内联插件访问图像

Accessing images from grails in-line plugin when deployed in a tomcat server

我有两个 grails 应用程序并创建了一个名为 cmcore 的内联插件。我在 cmcore/web-app/images 中放置了一些图像,以便我的两个应用程序都可以访问所述图像。图像在开发环境中被两个应用程序成功访问,但是每当我在测试环境中构建我的应用程序的 WAR 文件并将其部署在 tomcat 服务器中时,cmcore[=27 中的图像=] 变得不可访问,导致资源未找到错误。

我提取了生成的 WAR 文件,发现我的内联插件中的图像不存在于提取的 WAR 文件的 images 目录中,而是我找到了它在 plugins/cmcore-0.1/images.

我已经尝试了下面的代码来完成这项工作,但它仍然不起作用。

<img src="${resource(dir: 'images', file: 'logo.jpg')}" height="30" width="30">

当打包在 WAR 文件中并部署在服务器中时,应用程序如何访问这些图像?

提前致谢。

您想要访问 'plugin' 中的图像?试试这个:

<img src="${resource(dir: 'images', file: 'logo.jpg', plugin: 'cmcore')}" height="30" width="30">