티스토리 뷰

728x90
반응형

Client에서 Server로 데이터를 전송할 때 HTTP Request Headers에 content-type 설정에 따라
HTTP Request Message Body 데이터 포멧이 달라지기 때문에 Server에서 데이터 수신 방식이 달라짐

application/x-www-form-urlencoded

  • HTML form, .ajax 요청 헤더에 default content-type 값
  • key=value 포멧
  • Server Side 서블릿에서 Request Body를 Map 형태로 변환
  • Controller에서 @RequestParam, request.getParameter("param"), @ModelAttribute Command 객체 바인딩 가능

application/json

  • {"key" : "value"} 포멧
  • .ajax는 데이터를 문자열화 하지 않기 때문에 JSON.stringfy() 로 문자열 변환
  • Controller에서 @RequestBody로 Command 객체 바인딩 가능
728x90
반응형

'Spring' 카테고리의 다른 글

Spring ApplicationListener, EventListener  (0) 2022.01.11
Spring ApplicationContextInitializer  (0) 2022.01.11
[Spring] Filter vs. Interceptor  (0) 2020.05.19
Session, Cookie  (0) 2020.05.18
Spring MVC  (0) 2020.05.16
반응형
300x250