Grails resource log entry when using images with an absolute value: true

Using Grails 2.0.4. When creating emails, I use many images with absolute paths. Each of them leads to annoying journal entries. Is there an easy solution? They exist, it seems that the resource plugin does not like absolute paths. This also happens outside of localhost / dev.

<img src="${resource(dir: 'images/brochure', file: 'arrow_up.png', absolute: 'true')}" alt="Up" />

leads to

WARN  resource.ResourceTagLib  - Invocation of <r:resource> for a resource that apparently doesn't exist: http://localhost:8080/images/brochure/arrow_up.png
+5
source share
4 answers

The solution that works with me for Grails 2.1.x and higher (including the latest 2.3.x) adds these entries to your log4j configuration block in Config.groovy - no other code changes are required.

 log4j = {
           //your other stuff ...
            error 'grails.app.services.org.grails.plugin.resource'
            error 'grails.app.taglib.org.grails.plugin.resource'
            error 'grails.app.resourceMappers.org.grails.plugin.resource'
}
+3
source

, , , , Grails 2.3.x. ResourceTagLib resource, :

@todo = "" ,

, resource, :

...
if (!info.debug && log.warnEnabled) {
    log.warn "Invocation of <r:resource> for a resource that apparently doesn't exist: ${info.uri}"
}
...

:

...
if (attrs.absolute != true && !info.debug && log.warnEnabled) {
    log.warn "Invocation of <r:resource> for a resource that apparently doesn't exist: ${info.uri}"
}
...
0

, dir. uri. , dir .

( ):

<r:img uri="images/logo.png" width="100" height="50"/>
0

grails-resources. "". G-:

<img src="${g.resource(dir: 'images/brochure', file: 'arrow_up.png', absolute: 'true')}" alt="Up" />

R- ():

<img src="${r.resource(uri: 'images/brochure/arrow_up.png')}" />

-1

All Articles