Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 | 29 |
30 | 31 |
Tags
- Spring
- ์ด๋ถ ํ์
- DP
- ๋ฌธ์์ด
- dfs
- error
- ๋ฐฑํธ๋ํน
- ๊ตฌํ
- BFS
- OS
- java
- c++
- dynamic debugging
- Reversing
- ์ฐ์ ์์ ํ
- thymeleaf
- ๊ทธ๋ฆฌ๋
- ๋งต
- ์ฌ๊ท
- CVE
- JPA
- ๋์ ํฉ
- web
- ๋ถํ ์ ๋ณต
- ์๋ฎฌ๋ ์ด์
- ๋ฐ์ดํฌ์คํธ๋ผ
- ์ต๋จ ๊ฒฝ๋ก
- ์คํ
- GCP
- ์์ ์ ๋ ฌ
Archives
- Today
- Total
hades
[Thymeleaf] ๋ฐ๋ณต๋ฌธ ์ฌ์ฉ ์ ๋ณ์ ์ฌ์ฉ ์ฃผ์ ๋ณธ๋ฌธ
๐๐ปโ๏ธ ๊ธฐ๋ณธํ๋ จ/Spring
[Thymeleaf] ๋ฐ๋ณต๋ฌธ ์ฌ์ฉ ์ ๋ณ์ ์ฌ์ฉ ์ฃผ์
hades1 2024. 8. 20. 14:30๐จ ์๋ฌ
์นํจ3 ๊ฒ์๊ธ์ ์ง์ฐ๊ณ ์ถ์ด์ ์ญ์ ๋ฅผ ๋๋ฅด๋ฉด, ์๋์ ๊ฐ์ด ์นํจ1์ด ์ง์์ก๋ค.
action์ ๊ฒฝ๋ก๋ ์ ๋๋ก ๋ ๊ฒ์ ํ์ธํ๋๋ฐ, ์ ์ด๋ฐ ์ผ์ด ์ผ์ด๋๋ ๊ฒ์ผ๊น?
๐ ๋ถ์
<div class="post" th:each="post : ${posts}" >
<div th:each="imageFile : ${post.imageFiles}">
<img class="post-image" th:src="|/post/images/${imageFile.storeFileName}|">
</div>
<div class="post-content">
<div class="post-comment" th:text="${post.comment}"></div>
<div class="post-date" th:text="|${post.createdDateTime.toLocalDate()} ${post.createdDateTime.getHour()}:${post.createdDateTime.getMinute()}|"></div>
<form th:action="|/member/mypage/posts/modify/${post.id}|" method="get" id="myPost-modify">
</form>
<form th:action="|/member/mypage/posts/delete/${post.id}|" method="post" id="myPost-delete" onsubmit="return confirm('์ ๋ง ์ญ์ ๋ฅผ ์ํ์ญ๋๊น? ๋๋๋ฆด ์ ์์ต๋๋ค.');">
</form>
<button type="submit" form="myPost-modify" class="button-left">์์ </button>
<button type="submit" form="myPost-delete" class="button-right">์ญ์ </button>
</div>
</div>
๋ฌธ์ ๋ ๊ฒ์๊ธ์ ๋์ดํ ๋, th:each๋ฅผ ์ฌ์ฉํ์๊ณ , ์์ ๊ณผ ์ญ์ ๋ฒํผ์ ๋ฐฐ์นํ๋ ๊ณผ์ ์์ form์ id๋ฅผ ์ฌ์ฉํ๋๋ฐ, ์ด id๊ฐ ๊ฒ์๊ธ๋ง๋ค ๋ชจ๋ ๊ฐ๊ฒ ๋์ด ๋งจ ์์ ์๋ ๊ฒ์๊ธ์ด ์ง์์ง ๊ฒ์ด์๋ค.
๐ ํด๊ฒฐ
<div class="post" th:each="post : ${posts}" >
<div th:each="imageFile : ${post.imageFiles}">
<img class="post-image" th:src="|/post/images/${imageFile.storeFileName}|">
</div>
<div class="post-content">
<div class="post-comment" th:text="${post.comment}"></div>
<div class="post-date" th:text="|${post.createdDateTime.toLocalDate()} ${post.createdDateTime.getHour()}:${post.createdDateTime.getMinute()}|"></div>
<div class="post-modify">
<form th:action="|/member/mypage/posts/modify/${post.id}|" method="get">
<button type="submit">์์ </button>
</form>
</div>
<div class="post-delete">
<form th:action="|/member/mypage/posts/delete/${post.id}|" method="post" onsubmit="return confirm('์ ๋ง ์ญ์ ๋ฅผ ์ํ์ญ๋๊น? ๋๋๋ฆด ์ ์์ต๋๋ค.');">
<button type="submit">์ญ์ </button>
</form>
</div>
</div>
</div>
button์ form ์์ ๋ฃ๊ณ , div ํ๊ทธ์ ํด๋์ค๋ฅผ ์ด์ฉํ์ฌ ๋ฐฐ์นํ์๋ค.
'๐๐ปโโ๏ธ ๊ธฐ๋ณธํ๋ จ > Spring' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Spring] ์ธ์ฝ๋ฉํ ๊ฒฐ๊ณผ๋ ๋์ฝ๋ฉ (0) | 2024.08.22 |
---|---|
[Spring] BindingResult๋ ํ ํ๋ฆฟ์ ์ ๋ฌ (0) | 2024.08.21 |
[Spring] ๊ฒฝ๋ก ์ค์ ์ ๋์๋ฌธ์ ๊ตฌ๋ถ์ ์ค์์ฑ (0) | 2024.08.19 |
[Spring] ์คํ๋ง AI (0) | 2024.08.14 |
[Spring] ํ์ผ ์ ๋ก๋ (0) | 2024.08.13 |