我有一个 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”