当前位置: 代码迷 >> Java Web开发 >> JSP页面图片能显示出来,但是页面别的信息为空白解决方法
  详细解决方案

JSP页面图片能显示出来,但是页面别的信息为空白解决方法

热度:17   发布时间:2016-04-17 10:34:24.0
JSP页面图片能显示出来,但是页面别的信息为空白
<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>

------解决方案--------------------
重新理解了下你的逻辑思路后,终于大概知道你问题在哪了。

楼主你混淆了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();
%>

------解决方案--------------------
<img width="???" height="???" src="image.jsp?imageId=xxxooo" />
  相关解决方案