我想在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;"/>
但仍然没有显示图像,有人建议我这个解决方案