Grails:如何在<g:each>标签中显示图像?</g:each>

时间:2012-07-06 23:02:43

标签: image grails groovy each

  

可能重复:
  Grails: displaying created image in gsp

我正在尝试在<g:each>标记中显示数据库中的图像。

我的域类:

class Artists {
    byte[] image

    String artistName
    String bio

    static constraints = {
        image(nullable:true , maxSize:200000)
        artistName(nullable:true)
        bio(nullable:true, maxSize:2000)
    }

}

artists.gsp:

<g:each in="${dog.Artists.list()}">
    <g:img src="${it.image }" width="120" height="160"/>  //doesn't work, what should I do here???
    <p>Name: ${it.artistName}</p>                         //works  
    <p>Biography: ${it.bio}</p>                           //works
</g:each>
请帮忙!!!

1 个答案:

答案 0 :(得分:0)

您可以按照尝试使用渲染插件的方式内嵌渲染图像,以及以下gsp标记(这是png在其他内容类型的文档中检查Inline Images):

<rendering:inlinePng bytes="${it.image}"/>