我有一个Struts操作,写入HttpServletResponse
如下。代码仅适用于HTTP,但不适用于HTTPS。
BufferedInputStream in = null;
try {
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\";");
// set response headers
response.setContentLength(fileData.length);
response.setContentType("application/octet-stream");
//BUFFER
int bufferSize = 2 * 1024 * 1024;
in = new BufferedInputStream(new ByteArrayInputStream(fileData), bufferSize);
byte[] buffer = new byte[bufferSize];
int len = 0;
// Loop through the input file and get the data chunks...
while ((len = in.read(buffer, 0, bufferSize)) != -1) {
response.getOutputStream().write(buffer, 0, len);
}
} catch (Exception e) {
throw new SystemException(e.getMessage());
} finally {
response.getOutputStream().flush();
response.getOutputStream().close();
}
服务器是Weblogic 10(重要吗?)。整个Web应用程序使用HTTPS,文件下载除外。 它适用于Chrome和FF,但不适用于IE 8/9。以下消息显示在警告框中
Windows无法找到“https:// xxxxxxx”
答案 0 :(得分:4)
这是一个已知的特定于IE的问题,另请参阅Microsoft支持网站:Internet Explorer is unable to open Office documents from an SSL Web site。要解决此问题,您需要在响应中明确设置以下标头:
response.setHeader("Cache-Control", "public");
response.setHeader("Pragma", "public");