<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>
<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>
<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();
%>
报错
对不起,系统异常,给您带来不便,请谅解!
这个又是为什么呢?
request.getAttribute("morder")
是不存在的,因为这个时候已经没有servlet给你重定向了,所以之前servlet所产生的图片,早就没了。
所以本质上是你的设计思路上还没有绕过弯来:
负责显示页面的整个流程,跟负责读取和显示图片的整个流程,必须基本剥离开来。