【问题标题】:Grails: how to display images in <g:each> tag? [duplicate]Grails:如何在 <g:each> 标签中显示图像? [复制]
【发布时间】:2012-07-06 23:02:42
【问题描述】:

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

我正在尝试在&lt;g:each&gt; 标记中显示数据库中的图像。

我的域类:

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>

请帮忙!!!

【问题讨论】:

    标签: image grails groovy each


    【解决方案1】:

    您可以使用渲染插件和以下 gsp 标记(这是用于 png 检查 Inline Images 文档中的其他内容类型):

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

    【讨论】:

      猜你喜欢
      • 2020-12-26
      • 1970-01-01
      • 1970-01-01
      • 2016-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-10
      相关资源
      最近更新 更多