2016-06-20 1 views
0

그래서 다운로드하지 내가 가진 : 나는 그것을 표시해야처럼 csv로 텍스트를 볼 응답 탭에서 enter image description hereHTTP 응답 CSV 내 JAVA 컨트롤러에

:

여기
response.setContentType("text/csv"); 
    response.setHeader("Content-Disposition", "attachment; filename=\"export.csv\""); 

    try { 
     OutputStream outputStream = response.getOutputStream(); 
     String outputResult = "xxxx, yyyy, zzzz, aaaa, bbbb, ccccc, dddd, eeee, ffff, gggg\n"; 
     outputStream.write(outputResult.getBytes()); 
     outputStream.flush(); 
     outputStream.close(); 
    } catch (Exception e) { 
     System.out.println(e.toString()); 
    } 

는 검사 요소 네트워크 탭입니다 .

+0

원하는 동작을 설명하십시오. – omerts

+0

@omerts 저장 대화 상자가 나타나서 CSV를 저장해야합니다. – Dylan

답변

0

XMLHttpRequest를 사용하여 요청한 콘텐츠로 Content-Disposition을 사용하려는 것 같습니다. 그건 작동하지 않습니다.

+0

대신 무엇을해야합니까? – Dylan

+0

XmlHttpRequest를 통해 전송 된 요청의 동작에 영향을 줄 수있는 요소가 있다고 생각하지 않습니다. –