Image 是否加载会话用户图像,但不加载来自其他用户的图像?圣杯
按会话或登录用户加载和显示的图像显示良好,但不会显示来自会话用户以外的用户的图像。注意:每个图像加载的url都很好,只是图像不显示 图像控制器:Image 是否加载会话用户图像,但不加载来自其他用户的图像?圣杯,image,grails,Image,Grails,按会话或登录用户加载和显示的图像显示良好,但不会显示来自会话用户以外的用户的图像。注意:每个图像加载的url都很好,只是图像不显示 图像控制器: def thumbphoto = { response.setContentType('image/jpeg') response.setHeader('Cache-control', 'no-cache') if(params?.id != null && !(params?.id.empty)){
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()))
}
}
在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>
${status.id}:${status.message}
您正在覆盖id
id:status.photo
和params:[id:status.id]
编辑:
并且不传递userId
尝试创建链接并在其中添加用户ID:
谢谢,即使我从参数中删除了id,它也会加载图像url,但不会显示图像@IVARPRUDNIKOVEN即使我尝试从image controller中的thumbphoto方法中删除会话用户,它仍然会执行相同的操作…您没有传递用户ID
,因此会话中没有任何用户。好的,但是如果我想列出所有状态以及用户信息和图像,我将如何完成?这取决于您的型号,从您的查询中,我看到了c.user\u account\u id
,这就是为什么我在主要回答中添加了包含userId:status.userAccount.id
的示例,我只是不确定您是否可以通过这种方式访问用户id,以及它是否是您想要的
<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>