티스토리 뷰

TIL

타임리프(Thymeleaf)에 대해

해미깨미 2021. 2. 5. 21:43

오늘은 타임리프(Thyemleaf)를 사용하면서 있었던 문제점에 대해서 적어보려고 한다.

<form th:action="@{/api/v1/posts}"
      th:object="${requestDto}" method="post" accept-charset="UTF-8">

  <div>
    <label for="title">
        제목
    </label>
    <input type="text" name="title" th:field="*{title}">
  </div>

  <div>
    <label for="author">
        작성자
    </label>
    <input type="text" name="author" th:field="*{author}">
  </div>

  <div>
    <label for="content">
        내용
    </label>
    <textarea th:field="*{content}" name="content" id="content"
              cols="30" rows="10" placeholder="내용을 입력하세요"></textarea>
  </div>

  <button type="submit">등록</button>
  <a href="/">취소</a>

</form>

이 상태에서 계속 th:field="" 태그에 에러가 났었는데, 바로 컨트롤러에서 requestDto라는 이름의 빈 객체를 모델에 담아서 보내지 않아서 생긴 에러였다.

 

어찌 보면 참 당연한 건데 이걸 몰라서 구글링을 참 오랫동안 했다...

'TIL' 카테고리의 다른 글

자바(Java) 스레드(Thread) 공부  (0) 2021.02.07
스프링 어노테이션에 대해 알게 된 사실  (0) 2021.02.05
Spring 빌드 클린  (3) 2021.02.04
JPA 더티 체킹  (0) 2021.02.03
Java Optional 간단 요약 문서  (0) 2021.02.03
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함