Request Param은 URL에 표시하고 싶을때 사용
보통 몇개 안될때 사용한다.
public List<CommentResponse> read(@RequestParam Long postId){
return commentService.read(postId);
}
읽어올때는 Id값이 하나면 되니까 param을 사용한다. 그리고 필요한 정보가 id값이기 때문에 (소수이니까) param을 사용했다.
Request Body는 input이 많은 양일 때 사용한다.
@PostMapping("/comments")
public CommentResponse create(@RequestBody CommentRequest commentRequest){
return commentService.save(commentRequest);
}
만들때는 여러개를 input으로 받기 때문에 Request로 받는다.