0

会话或登录用户的图像加载并显示正常,但会话用户以外的用户的图像不会显示。注意:每个图像的 url 加载都很好,它的只是图像不显示。

图像控制器:

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>
4

1 回答 1

0

您正在覆盖 id id:status.photoparams:[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="" />

于 2013-06-06T23:41:14.507 回答