<h1>글 작성 페이지</h1>
<form action="/board/save" method="post" th:object="${boardDto}">
<input type="hidden" th:field="*{id}" />
<div class="mb-3">
<label for="title" class="form-label">타이틀</label>
<input type="text" id="title" th:field="*{title}" class="form-control" placeholder="제목을 입력해주세요">
</div>
<p th:if="${#fields.hasErrors('title')}" th:errors="*{title}" class="fieldError">잘못된 데이터입니다.</p>
<div class="mb-3">
<label for="writer" class="form-label">작성자</label>
<input type="text" id="writer" th:field="*{writer}" class="form-control" placeholder="작성자를 입력해주세요">
</div>
<p th:if="${#fields.hasErrors('writer')}" th:errors="*{writer}" class="fieldError">잘못된 데이터입니다.</p>
<div class="mb-3">
<label for="content" class="form-label">내용</label>
<textarea id="content" class="form-control" aria-label="With textarea" th:field="*{content}" placeholder="내용을 입력해주세요"></textarea>
</div>
<div th:if="${#strings.isEmpty(boardDto.id)}" style="text-align: center">
<button th:formaction="@{/admin/item/new}" type="submit" class="btn btn-primary">저장</button>
</div>
<div th:unless="${#strings.isEmpty(boardDto.id)}" style="text-align: center">
<button th:formaction="@{'/admin/item/' + ${itemFormDto.id} }" type="submit" class="btn btn-primary">수정</button>
</div>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
</form>
카페 게시글
스프링(Spring)
thymeleaf
글 작성을 위한 기본 틀(Form)
주인장
추천 0
조회 7
25.02.02 18:16
댓글 0
다음검색