0
나는 서블릿을 통해 다운로드 파일이 방법이 있고, 인터넷 익스플로러다운로드 파일
public void downloadFile(HttpServletResponse response, String filePath) throws FileNotFoundException, IOException
{
System.out.println(response.toString());
File downloadFile = new File(filePath);
OutputStream outStream;
// gets MIME type of the file
try (FileInputStream inStream = new FileInputStream(downloadFile)) {
// gets MIME type of the file
String mimeType = "application/octet-stream";
System.out.println("MIME type: " + mimeType);
// modifies response
response.setContentType(mimeType);
response.setContentLength((int) downloadFile.length());
// forces download
String headerKey = "Content-Disposition";
String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName());
response.setHeader(headerKey, headerValue);
//response.setHeader("Cache-Control", "max-age=60");
// obtains response's output stream
outStream = response.getOutputStream();
byte[] buffer = new byte[4096];
int bytesRead = -1;
while ((bytesRead = inStream.read(buffer)) != -1) {
outStream.write(buffer, 0, bytesRead);
}
}
outStream.close();
}
테스트를 위해 리소스를 온라인 상태로 설정할 수 있습니까? 서버가 응답 할 때 네트워크 탭의 F12 개발자 도구에 어떤 응답이 표시됩니까? 이 문제는 [KB279667] (http://support.microsoft.com/kb/279667/)과 관련된 것으로 보입니다. 모든 업데이트가 설치되어 있습니까? – Sampson