record 타입이 작성이 편해서 사용중이었다.
그런데 update 동작에서 문제가 생겼다.
post_submit 페이지를 수정용도로 재활용하려고 했다.
이때 코드상에서 문제가 생겼다.
@GetMapping("/update/{id}")
public String updatePost(CreatePostRequest request, @PathVariable("id") Long id) {
Post post = postService.findById(id);
request = new CreatePostRequest(post.getTitle(), post.getContent());
return "post_update";
}
request 를 새로운 record 로 대체하면 페이지에서 값이 입력되지 않았다.
그래서 class 타입으로 선언해야했다.