0

我想在 grails 项目的列表视图中显示图像

我在控制器中编写了一个动作,用于在列表中显示它

def showImage () {
    def testUnitInstance = TestUnit.get(params.testUnitId)
    response.setContentType("image/jpeg")
    response.setContentLength(testUnitInstance.image.size())
    response.outputStream << testUnitInstance.image
    response.outputStream.flush()
    }

在列表视图中,我调用了该操作

<img src="<g:createLink controller='testUnit' action='showImage' 
                    params='[testUnitId:testUnitInstance.id]'/>" height="14px" width="14px" alt="img"
                                    style="padding-left: 20px;"/>

但仍然没有显示图像有人建议我解决这个问题

4

0 回答 0