Project/Study Website Project
[Spring Boot Project] 게시글 리스트 및 상세 페이지
seung_hyeon
2025. 1. 14. 00:24

리스트 테스트를 위해 위 코드로 게시글을 만듦
- 게시글 리스트



- 리스트 게시글 클릭


PostView.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>게시글 리스트 페이지</title>
</head>
<style>
.layout {
width: 500px;
margin: 0 auto;
margin-top: 40px;
}
</style>
<body>
<div class="layout">
<table >
<thead>
<tr>
<th>글 번호</th>
<th>제목</th>
</tr>
</thead>
<tbody>
<tr th:each="post : ${list}">
<td th:text="${post.id}">1</td>
<td>
<a th:text="${post.title}" th:href="@{/post/view(id=${post.id})}"></a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
PostView.html
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>게시글 상세 페이지</title>
</head>
<body>
<h1 th:text = "${post.title}">제목입니다.</h1>
<p th:text = "${post.content}">내용이 들어갈 부분입니다.</p>
</body>
</html>