<td class="tdright" style="padding-right: 4px;">凭证图片</td>
<td class="tdright">
<%
byte[] a = ((MdeliveryOrder)request.getAttribute("morder")).getVoucherImg();
response.setContentType("image/gif");
OutputStream o = response.getOutputStream();
o.write(a);
o.flush();
o.close();
%>
</td>

解决方案 »

  1.   

    o.close();你都把response的输出流给close()了,后面还能输出啥啊?
      

  2.   

    outputstram把你的数据写到内存中去了,不读取当然是空白了
      

  3.   

    重新理解了下你的逻辑思路后,终于大概知道你问题在哪了。楼主你混淆了HTML页面和图片吧?企图把HTML页面和图片一起输出是做不到的。出库单页面中,只能是类似这样:
    <td class="tdright" style="padding-right: 4px;">凭证图片</td>
    <td class="tdright">
      <img src="image.jsp?imageId=xxxooo" />
    </td>
    然后另外写个image.jsp
    <%
    byte[] a = ((MdeliveryOrder)request.getAttribute("morder")).getVoucherImg();
    response.setContentType("image/gif");
    OutputStream o = response.getOutputStream();
    o.write(a);
    o.flush();
    %>
      

  4.   

    可是我另写了一个页面为什么图片就读不出来了呢?单独显示那个页面http://localhost:8080/skeleton/m/img.jsp
    报错
    对不起,系统异常,给您带来不便,请谅解!  
    这个又是为什么呢?
      

  5.   

    那要看后台错误的详细信息了。不过主要问题应该是:
    request.getAttribute("morder")
    是不存在的,因为这个时候已经没有servlet给你重定向了,所以之前servlet所产生的图片,早就没了。
    所以本质上是你的设计思路上还没有绕过弯来:
    负责显示页面的整个流程,跟负责读取和显示图片的整个流程,必须基本剥离开来。
      

  6.   

    将request.getAttribute改为application.getAttribute图片就显示出来了。虽然不知道为什么application.getAttribute就能显示图片。但是显示的图片超级大。该如何缩略呢?
      

  7.   

     <img width="???" height="???" src="image.jsp?imageId=xxxooo" />