在我的JSP中,我有一些从jsp获取字节数组的代码:
photo.innerHTML = "<img src='" + "<%=getPictureUrl%>" + "&pidm=" + x[i].getAttribute("pidm") + "'></img>";并将用户的唯一ID附加为url参数。在java端,我获取图像并将其转换为字节数组。
InputStream is = connection.getInputStream();
System.out.print("getInputStream ");
if (is instanceof ByteArrayInputStream) {
size = is.available();
buf = new byte[size];
len = is.read(buf, 0, size);
}
else {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
buf = new byte[size];
while ((len = is.read(buf, 0, size)) != -1)
bos.write(buf, 0, len);
buf = bos.toByteArray();
}
o.write(buf);
o.flush();
o.close();这在Firefox和Chrome中运行良好,但在IE中,会显示一个带有"x“的黑框,就像浏览器找不到图像一样。在IE中是否需要做一些特殊的事情来解决这个问题?我在web控制台中没有看到任何错误。
发布于 2016-05-27 23:47:36
忘记设置我的回复内容类型:
response.setContentType("image/jpeg");https://stackoverflow.com/questions/37486641
复制相似问题