타임리프 th:filed

Sol's·2023년 1월 23일
0

오류

목록 보기
16/18

타임리프를 통해 게시글을 등록하려고 하던중 오류를 만났습니다.

Post를 등록할때 Dto에 값을 넣는도중 에러가 발생했는데
Setter가 없어서 넣지를 못하나? 라는 생각을 하였고
Setter를 넣어주니 문제가 해결되었습니다.

@AllArgsConstructor
@NoArgsConstructor
@Builder
@Getter
public class PostOneResponse{
    private Long id;
    private String title;
    private String body;
    private String userName;

    private LocalDateTime createdAt;
    private LocalDateTime lastModifiedAt;

    public static PostOneResponse fromEntity(Post post) {
        return PostOneResponse.builder()
                .id(post.getId())
                .title(post.getTitle())
                .body(post.getBody())
                .userName(post.getUser().getUserName())
                .createdAt(post.getCreatedAt())
                .lastModifiedAt(post.getLastModifiedAt())
                .build();
    }
}

profile
배우고, 생각하고, 행동해라

0개의 댓글