Skip to content

Form에서 넘긴 input을 받을 때 @RequestBody 쓰지 말것 #2

@1876070677

Description

@1876070677

@RequestBody의 경우 application/json 요청을 매핑할 때 사용된다.

Form은 기본적으로 콘텐트 타입을 x-www-form-urlencoded 로 사용하기 때문에 @RequestBody 어노테이션을 사용할 경우 정상적으로 요청의 바디에 포함된 데이터가 매핑되지 않는다.

x-www-form-urlencoded는 일종의 쿼리 스트링으로 인코딩 된다(키1=value1&키2=value2...)

이런 경우, 어노테이션을 제거하면 해결된다. 실제로는 @ModelAttribute가 생략되어 있는 것이다.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions