From 25523700d62cf860fc8c46c2252de6d017e60b28 Mon Sep 17 00:00:00 2001 From: haerong22 Date: Mon, 5 Jul 2021 20:44:58 +0900 Subject: [PATCH] each --- .../thymeleaf/basic/BasicController.java | 14 ++++++ .../main/resources/templates/basic/each.html | 44 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 thymeleaf/src/main/resources/templates/basic/each.html diff --git a/thymeleaf/src/main/java/com/example/thymeleaf/basic/BasicController.java b/thymeleaf/src/main/java/com/example/thymeleaf/basic/BasicController.java index bd524154..2dfa23d3 100644 --- a/thymeleaf/src/main/java/com/example/thymeleaf/basic/BasicController.java +++ b/thymeleaf/src/main/java/com/example/thymeleaf/basic/BasicController.java @@ -90,6 +90,20 @@ public class BasicController { return "basic/attribute"; } + @GetMapping("/each") + public String each(Model model) { + addUsers(model); + return "basic/each"; + } + + private void addUsers(Model model) { + List list = new ArrayList<>(); + list.add(new User("userA", 10)); + list.add(new User("userB", 20)); + list.add(new User("userC", 30)); + model.addAttribute("users", list); + } + @Component("helloBean") static class HelloBean { public String hello(String data) { diff --git a/thymeleaf/src/main/resources/templates/basic/each.html b/thymeleaf/src/main/resources/templates/basic/each.html new file mode 100644 index 00000000..9fa2c809 --- /dev/null +++ b/thymeleaf/src/main/resources/templates/basic/each.html @@ -0,0 +1,44 @@ + + + + + Title + + +

기본 테이블

+ + + + + + + + + +
usernameage
username0
+

반복 상태 유지

+ + + + + + + + + + + + + +
countusernameageetc
usernameusername0 + index = + count = + size = + even? = + odd? = + first? = + last? = + current = +
+ + \ No newline at end of file