728x90
memberController list 메서드

memberList.html
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/header :: header" />
<body>
<div class="container">
<div th:replace="fragments/bodyHeader :: bodyHeader" />
<div>
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>이름</th>
<th>도시</th>
<th>주소</th>
<th>우편번호</th>
</tr>
</thead>
<tbody>
<tr th:each="member : ${members}">
<td th:text="${member.id}"></td>
<td th:text="${member.name}"></td>
<td th:text="${member.address?.city}"></td>
<td th:text="${member.address?.street}"></td>
<td th:text="${member.address?.zipcode}"></td>
</tr>
</tbody>
</table>
</div>
<div th:replace="fragments/footer :: footer" />
</div> <!-- /container -->
</body>
</html>
- memberList를 받아 출력하는 폼으로 보내준다.
- 참고 : Entity에 화면을 받아오는 기능을 쓰게 되면 유지보수가 점점 힘들어진다.
- 화면에 종속적인 코드가 계속 증가되기 때문에 점점 엔티티가 화면에 종속적으로 변경되게 된다(유지보수가 힘들어진다)
- 참고 : Api를 만들 때에는 엔티티를 절대 반환해서는 안된다.
- Entity에 속성이 추가되면 api스펙이 변화된다(Entity가 API가 변경되는 큰 문제가 발생된다)
- thymeleaf을 장점이 보이는 코드로 html태그를 그대로 쓸 수가 있다.
728x90
'실전! 스프링 부트와 JPA 활용1(웹 애플리케이션 개발)' 카테고리의 다른 글
| Ch07. 웹 계층 개발 - 상품 수정 (0) | 2021.12.07 |
|---|---|
| Ch07. 웹 계층 개발 - 상품 등록, 상품 목록 (0) | 2021.12.07 |
| Ch07. 웹 계층 개발 - 회원 등록 (0) | 2021.12.07 |
| Ch07. 웹 계층 개발 - 홈 화면과 레이아웃 (0) | 2021.12.07 |
| Ch06. 상품 도메인 개발 - 주문 검색 기능 개발 (0) | 2021.12.06 |