[Thymeleaf] th:object, th:field 사용법
·
Server/Spring&Spring Boot
타임리프를 사용하기 위해, 여러 블로그들을 찾다 보면 th:object로 DTO에 값을 전달해 주는 코드를 많이 보게 되었다. 무작정 th:object에 PostMapping에서 @ModelAttribute에 name으로 지정된 값을 작성하면 빨간 줄이 뜨면서 에러가 발생하였다. th:object는 어떻게 사용할 수 있을까? Controller Controller에서 해당 View를 받아오는 @GetMapping이 된 웹서버에 th:object로 사용할 객체를 생성하여 Model로 저장해 주어야 th:object를 사용할 수 있다. @GetMapping("/writeForm") public String writeForm( @SessionAttribute(name = "loginUser", required..