2012-07-06 92 views
0

可能重複:
Grails: displaying created image in gspGrails:如何在<g:each>標籤中顯示圖片?

我想在<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> 

幫助請!

回答

0

可以渲染圖像內聯您所使用的渲染插件嘗試的方式,和下面的GSP標籤(這是一個PNG檢查Inline Images在文檔中的其他內容類型):

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