按会话映射或登录用户加载并显示正常,但会话用户以外的用户的图像将不会显示。注意:每个图像的网址加载都很好,它的图像不会显示。
图像控制器:
def thumbphoto = {
response.setContentType('image/jpeg')
response.setHeader('Cache-control', 'no-cache')
if(params?.id != null && !(params?.id.empty)){
params.maxWidth?: 50.00
params.maxHeight?: 50.00
response.outputStream << imageProxyService.loadThumbnailImage(params.id, securityService.passwordEncoder(userId.toString()))
}
}
查询输出图像和标语
def statusQuery = """SELECT c.user_account_id as userId, c.status_message as message, c.status_type as profile, se.id, se.photo FROM user_account se, status c
WHERE
c.user_account_id = se.id
GROUP BY se.id, c.user_account_id, c.status_message, c.status_type, se.photo"""
在gsp中显示图像:
<g:each in="${statusList}" status="i" var="status" status="i">
<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
<tr>
<td>
<img id="profile_photo" src="${createLink(controller:'image', action:'thumbphoto', id:status.photo, params:[maxWidth:50.0,maxHeight:50.0])}" alt="" title="" />
</td>
<td>${status.id}: ${status.message}</td>
</tr>
答案 0 :(得分:0)
你正在覆盖id
id:status.photo
和params:[id:status.id]
编辑:
而不是传递userId
尝试创建链接并在其中添加userId:
<img id="profile_photo" src="${createLink(controller:'image', action:'thumbphoto', id:status.photo, params:[userId:status.userAccount.id, maxWidth:50.0,maxHeight:50.0])}" alt="" title="" />