Skip to content

Commit

Permalink
feat : Member Look up function add
Browse files Browse the repository at this point in the history
  • Loading branch information
5w31892p committed Jan 13, 2023
1 parent bcfcb31 commit fbfdc75
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/hello/hellospring/controller/MemberController.java
@@ -1,7 +1,10 @@
package hello.hellospring.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

Expand Down Expand Up @@ -31,4 +34,11 @@ public String create(MemberForm memberForm) {

return "redirect:/";
}

@GetMapping(value = "/members")
public String list(Model model) {
List<Member> members = memberService.findMember();
model.addAttribute("members", members);
return "members/memberList";
}
}
23 changes: 23 additions & 0 deletions src/main/resources/templates/members/memberList.html
@@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div class="container">
<div>
<table>
<thead>
<tr>
<th>#</th>
<th>이름</th>
</tr>
</thead>
<tbody>
<tr th:each="member : ${members}">
<td th:text="${member.id}"></td>
<td th:text="${member.name}"></td>
</tr>
</tbody>
</table>
</div>
</div> <!-- /container -->
</body>
</html>

0 comments on commit fbfdc75

Please sign in to comment.