2014-11-26 5 views
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();  
} 
+0

테스트를 위해 리소스를 온라인 상태로 설정할 수 있습니까? 서버가 응답 할 때 네트워크 탭의 F12 개발자 도구에 어떤 응답이 표시됩니까? 이 문제는 [KB279667] (http://support.microsoft.com/kb/279667/)과 관련된 것으로 보입니다. 모든 업데이트가 설치되어 있습니까? – Sampson

답변

0

나는 클라이언트를 확인 (I 버전 11 시도)에 크롬과 모질라에서 잘 작동하지만 href가있는 hiperlink가 탐색기에서 작동하지 않는다는 것을 알게되면 javascript에서 리디렉션을 만들었습니다. 방법은 내가 잘 작동하는 게시물입니다.

관련 문제