Notice
Recent Posts
Recent Comments
Link
It won't hurt to try
[스프링 입문]17.회원 웹 기능 - 조회 본문
thymeleaf를 사용해서 회원의 아이디와 이름을 출력하는 화면이다.
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Members</title>
</head>
<body>
<div class="container">
<table>
<thead>
<tr>
<th>#</th>
<th>이름</th>
</tr>
</thead>
<tbody>
<tr th:each="member: ${members}">
<td th:text="${member.getId()}"></td>
<td th:text="${member.getName()}"></td>
<br>
</tr>
</tbody>
</table>
</div>
</body>
</html>
member.getId() 대신에 member.id라고 적어도 된다.
자바의 property방식인 getter/setter이기 때문에 id에 접근할때 getId()에 접근하게 된다.
th:each를 사용하면 loop문을 사용할수 있게 된다.
자세한 사용방법은 밑의 자료처럼 thymeleaf iteration관련한 여러 자료들을 참조하면 좋다.
https://www.baeldung.com/thymeleaf-iteration
단축키
Shift + option + ↑/↓: 행 이동
Cmd + e : 최근에 본 리소스들 확인
300x250
300x250
'JAVA > 스프링 입문' 카테고리의 다른 글
[스프링 입문]19.순수 JDBC (0) | 2021.08.17 |
---|---|
[스프링 입문]18.H2 데이터베이스 설치 (0) | 2021.08.14 |
[스프링 입문]16.회원 웹 기능 - 홈 화면 추가, 등록 (0) | 2021.08.09 |
[스프링 입문]15.자바 코드로 직접 스프링 빈 등록하기 (0) | 2021.08.07 |
[스프링 입문]14.컴포넌트 스캔과 자동 의존관계 설정 (0) | 2021.08.07 |
Comments