Published: 10 Jun 2019 › Updated: 10 Jun 2019
도리안의 개발 이야기 #170 - Spring으로 만든 API에서 JSON 입력자료에 내용이 없는 문제
대문 제작: imrahelk
개발 중인 Spring 프로젝트에 rest API를 추가했는데, JSON 입력 자료에 아무 내용이 없는 문제가 발견되었습니다. 혹시 API 실행 전에 입력 자료가 안 만들어진 건 아닌가 확인해보았으나 문제가 없었습니다. 그렇다면 도대체 어디에서 잘못된 것인지... 잠시 헤매다가 원인을 발견했습니다. 원인은 입력 자료를 받을 파라메터에 @RequestBody를 추가하지 않았기 때문입니다.
@RequestMapping(value = "...", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> newAPI(@RequestBody Map<String, Object> mapParams) {
// ...
}
위 코드와 같이 mapParams 파라메터의 앞에 @RequestBody를 추가해야 했는데, 그게 없어서 mapParams는 아무 내용도 받지 못하고 비어 있었던 것입니다. Spring에 대해 아는 게 없다 보니 이런 문제로도 헤매게 됩니다. 그래서 공부를 열심히 해야 합니다.
Leave 도리안의 개발 이야기 #170 - Spring으로 만든 API에서 JSON 입력자료에 내용이 없는 문제 to:
Read more #kr-dev posts
Best Posts From dorian-dev
We have not curated any of dorian-dev's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From dorian-dev
- My Actifit Report Card: June 10 2026
- My Actifit Report Card: June 8 2026
- My Actifit Report Card: June 3 2026
- My Actifit Report Card: May 27 2026
- My Actifit Report Card: May 26 2026
- My Actifit Report Card: May 18 2026
- My Actifit Report Card: May 16 2026
- My Actifit Report Card: May 14 2026
- My Actifit Report Card: May 11 2026
- My Actifit Report Card: May 10 2026
- My Actifit Report Card: May 7 2026
- My Actifit Report Card: May 4 2026
- My Actifit Report Card: May 3 2026
- My Actifit Report Card: May 2 2026
- My Actifit Report Card: April 30 2026
- My Actifit Report Card: April 29 2026
- My Actifit Report Card: April 27 2026
- My Actifit Report Card: April 26 2026
- My Actifit Report Card: April 24 2026
- My Actifit Report Card: April 23 2026