【发布时间】:2015-07-03 05:44:15
【问题描述】:
我目前在 Safari(Yosemite OS X 版本)中显示来自 java 字节流的 jpgs 时遇到问题。该图像在所有其他浏览器(包括早期版本的 Safari)中都能正常显示。有人知道最新版本的 Safari 显示 jpg 的任何错误吗?有没有其他人遇到过这个问题并有解决方法。
byte[] checkImage = checkImageString.getBytes(CommonConstants.ENCODING);
checkImage = Base64.decodeBase64(checkImage);
if ( null != checkImage ) {
int imageLength = checkImage.length;
response.setContentType(CommonConstants.JPEG_MIME_TYPE);
response.setContentLength(imageLength);
// to prevent caching
response.setHeader( CommonConstants.ACCEPT_RANGES_HEADER, CommonConstants.BYTES);
response.setHeader( CommonConstants.EXPIRES_HEADER, CommonConstants.EXPIRE );
response.setHeader( CommonConstants.CACHE_CONTROL_HEADER, CommonConstants.NO_CACHE );
response.setHeader( CommonConstants.PRAGMA_HEADER, CommonConstants.NO_CACHE );
response.setStatus(HttpServletResponse.SC_OK);
ServletOutputStream sos = response.getOutputStream();
sos.write(checkImage, 0, imageLength);
sos.flush();
sos.close();
}
【问题讨论】:
标签: java utf-8 safari jpeg osx-yosemite