November 18, 2024
<tbody>
<tr th:each="post : ${postList}">
<td>
<a th:href="@{|/post/detail/${post.id}|}" th:text="${post.title}"></a>
</td>
<td th:text="${post.createDate}"></td>
</tr>
</tbody>
/post/list
에서 특정 포스트를 선택하면 /post/detail/{id}
로 리다이렉트@Controller
@RequestMapping("/post") //URL 프리픽스
class PostController(
답변 기능
<form th:action="@{|/comment/create/${post.id}|}" method="post">
<textarea name="content" id="content" rows="15"></textarea>
<input type="submit" value="답변등록">
</form>
/comment/create/{id}
url이 호출됨November 19, 2024
부트스트랩 적용
post_list.html에 부트스트랩 적용
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap.min.css}">
<div class="container my-3">
<head>
<meta charset="UTF-8">
<title>Kchabin's Blog</title>
</head>
<h2>블로그 게시물</h2>
<table class="table">
<thead class="table-dark">
<tr>
<th>번호</th>
<th>제목</th>
<th>작성일시</th>
</tr>
</thead>
<tbody>
<tr th:each="post, loop : ${postList}">
<td th:text="${loop.count}"></td>
<td>
<a th:href="@{|/post/detail/${post.id}|}" th:text="${post.title}"></a>
</td>
<td th:text="${#temporals.format(post.createDate, 'yyyy-MM-dd HH:mm')}"></td>
</tr>
</tbody>
</table>
</div>
loop.count
를 사용하여 표시함.#temporals.format
기능을 사용해서 날짜를 원하는 형태로 출력할 수 있음