[Spring] setheader, Content-Disposition 정리

[Spring] setheader, Content-Disposition 정리

setHeader(Object headers)

  • Sets the headers for the web service response.
    • 웹 response를 위해서 해더를 설정
  • return값 -> void
  • A javaScript object listing each header and the value to assign that header
    • 각각의 헤더와 해당 헤더를 할당할 값에 나열하는 자바스크립트 객체
var headers = {};
headers.X-Total-Count=100;
headers.Location=‘https://instance.service-now.com/';
response.setHeaders(headers);



Content-Disposition

  • HTTP response에서 그 컨텐츠가 inline(default)으로 보여질것인지 아니면
    attachment로 다운로드 되어서 로컬에 저장될 것인지를 결정
Content-Disposition: inline
Content-Disposition: attachment
Content-Disposition: attachment; filename="filename.jpg"
  • ;(세미콜론)을 기준으로 여러 파라미터를 추가 가능
    • 단 맨 처음은 form-data탕비 와야 함
Content-Disposition: form-data
Content-Disposition: form-data; name="fieldName"
Content-Disposition: form-data; name="fieldName"; filename="filename.jpg"

res.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + "real file name");
//이런 식으로 사용

댓글

이 블로그의 인기 게시물

[Python] # -*- coding: utf-8 -*-를 쓰는 이유

[소프트웨어공학] NS(Nassi-Schneiderman) 차트

[컴퓨터네트워크] Telnet이란?