๐ฅ LikeLion_Final_Project [1์ฃผ์ฐจ] : ๊ตฌํ
๋ฐ๋ก ์ ๋ฆฌ : https://like099.tistory.com/40
[1์ฃผ์ฐจ] Mission ํด๊ฒฐ ์ผ์ง (1)
โณ๏ธ ๊ธ CRUD ๊ตฌํ ๐ ๊ธ ์ ์ฅํ๊ธฐ 1๏ธโฃ ์กฐ๊ฑด ํ์ธ โณ๏ธ API : GET /post/write โ๏ธ ํผ ์ ๋ ฅ โ subject โก content โข keywords (์ ๋ ฅ์์ : #์๋ฐ #์คํ๋ง๋ถํธ #์คํ๋ง๋ฐฐ์น) โณ๏ธ ์๊ตฌ์ฌํญ โ๏ธ ๋งํฌ๋ค์ด ์๋ฌธ
like099.tistory.com
๐โ๏ธ QNA ์๋น์ค ๊ธฐ๋ฅ ๊ตฌํ (๋ณต์ต) _ 119๊ฐ ~ 119๊ฐ
1๏ธโฃ th:field ์ ์ญํ
๊ฐ๊ฐ ํ๋๋ค์ ๋งคํ ํด์ฃผ๋ ์ญํ ์ ํ๋ค. ์ค์ ํด ์ค ๊ฐ์ผ๋ก, th:object ์ ์ค์ ํด ์ค ๊ฐ์ฒด์ ๋ด๋ถ์ ๋งค์นญํด์ค๋ค.
<form method="POST" th:action="@{/question/create}" th:object="${requestQuestionForm}" class="my-3">
<div class="alert alert-danger" role="alert" th:if="${#fields.hasAnyErrors()}">
<div th:each="err : ${#fields.allErrors()}" th:text="${err}" />
</div>
<div class="mb-3">
<label for="subject"> ์ง๋ฌธ ์ ๋ชฉ</label>
<input type="text" id="subject" name="subject" th:field="*{subject}" class="form-control">
</div>
<div class="mb-3">
<label class="form-label">์ง๋ฌธ ๋ด์ฉ</label>
<textarea name="content" class="form-control" rows="10" th:field="*{content}"></textarea>
</div>
<input type="submit" value="์ ์ฅํ๊ธฐ" class="btn btn-primary my-2">
</form>
โก๏ธ form ์๋ฆฌ๋จผํธ ์์ ์ ์ธํ th:object ์ ์ํด requestQuestionForm ๊ฐ์ฒด๊ฐ th:field ์ ๋ด์ฉ๋ค๊ณผ ๋งคํ๋๋ค. (2๋ฒ์งธ ์ค์์๋ #fields ์์ input ๊ณผ textarea ์ th:field ์์ ํ์ธ ๊ฐ๋ฅ)
'TIL ๐' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| TIL 11์ผ์ฐจ (2022.10.21) (0) | 2022.10.21 |
|---|---|
| TIL 10์ผ์ฐจ (2022.10.20) (0) | 2022.10.20 |
| TIL 8์ผ์ฐจ (2022.10.18) (0) | 2022.10.18 |
| TIL 7์ผ์ฐจ (2022.10.17) (0) | 2022.10.17 |
| TlL 6์ผ์ฐจ (2022.10.14) (0) | 2022.10.14 |