0

在 grails 中,图像 url 加载正常,但图像不显示......

def thumbphoto = {
    response.setContentType('image/jpeg')
    response.setHeader('Cache-control', 'no-cache')

    if(params.id){
      userId = params.id
    }
    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>
            <g:if test="${status.photo != null  && !(status.photo.empty)}" >
                  <img id="profile_photo" src="${createLink(controller:'image', action:'thumbphoto', id:status.photo, params:[maxWidth:50.0,maxHeight:50.0,id:status.id])}" alt="" title="" />

            </g:if>
            <g:else>
              <img id="profile_photo" src="${resource(dir:'images', file:'no_image_blue.gif')}" alt="No Image" width="50" height="50"/>
            </g:else>
            </td>
            <td>${status.id}: ${status.message}</td>
            </tr>
            </tr>
          </g:each>
4

2 回答 2

1

使用g:img

<g:img dir="/image/showImage/9921355add3b115766ad41effdf000db9e461570.jpg" alt=""/>
于 2013-06-03T23:16:10.733 回答
1

安装Firebug,然后转到Net选项卡。

您应该会看到所有 HTTP 请求及其状态。

您可能会为您的图像获得404,检查它在您的webapps文件夹下的位置...

Firebug 将再次为您提供所有提示和解决方案。

于 2013-06-03T23:00:49.217 回答