From 00c9a269dd1bbf87cbc5cdb8d453c4ee4d23bd19 Mon Sep 17 00:00:00 2001 From: haerong22 Date: Mon, 12 Jul 2021 19:25:35 +0900 Subject: [PATCH] thymeleaf_form : select box --- .../itemservice/web/form/FormItemController.java | 11 +++++++++++ .../src/main/resources/templates/form/addForm.html | 11 +++++++++++ .../src/main/resources/templates/form/editForm.html | 11 +++++++++++ .../src/main/resources/templates/form/item.html | 11 +++++++++++ 4 files changed, 44 insertions(+) diff --git a/thymeleaf_form/src/main/java/hello/itemservice/web/form/FormItemController.java b/thymeleaf_form/src/main/java/hello/itemservice/web/form/FormItemController.java index c3c6eade..0dd96d5d 100644 --- a/thymeleaf_form/src/main/java/hello/itemservice/web/form/FormItemController.java +++ b/thymeleaf_form/src/main/java/hello/itemservice/web/form/FormItemController.java @@ -1,5 +1,6 @@ package hello.itemservice.web.form; +import hello.itemservice.domain.item.DeliveryCode; import hello.itemservice.domain.item.Item; import hello.itemservice.domain.item.ItemRepository; import hello.itemservice.domain.item.ItemType; @@ -10,6 +11,7 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.mvc.support.RedirectAttributes; +import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -36,6 +38,15 @@ public class FormItemController { return ItemType.values(); } + @ModelAttribute("deliveryCodes") + public List deliveryCodes() { + List deliveryCodes = new ArrayList<>(); + deliveryCodes.add(new DeliveryCode("FAST", "빠른 배송")); + deliveryCodes.add(new DeliveryCode("NORMAL", "일반 배송")); + deliveryCodes.add(new DeliveryCode("SLOW", "느린 배송")); + return deliveryCodes; + } + @GetMapping public String items(Model model) { List items = itemRepository.findAll(); diff --git a/thymeleaf_form/src/main/resources/templates/form/addForm.html b/thymeleaf_form/src/main/resources/templates/form/addForm.html index 943e0227..3bba125a 100644 --- a/thymeleaf_form/src/main/resources/templates/form/addForm.html +++ b/thymeleaf_form/src/main/resources/templates/form/addForm.html @@ -62,6 +62,17 @@ + +
+
배송 방식
+ +
+ +
+
diff --git a/thymeleaf_form/src/main/resources/templates/form/editForm.html b/thymeleaf_form/src/main/resources/templates/form/editForm.html index 439be8d9..5839325c 100644 --- a/thymeleaf_form/src/main/resources/templates/form/editForm.html +++ b/thymeleaf_form/src/main/resources/templates/form/editForm.html @@ -67,6 +67,17 @@
+ +
+
배송 방식
+ +
+ +
+
diff --git a/thymeleaf_form/src/main/resources/templates/form/item.html b/thymeleaf_form/src/main/resources/templates/form/item.html index 9faa7d7c..43690319 100644 --- a/thymeleaf_form/src/main/resources/templates/form/item.html +++ b/thymeleaf_form/src/main/resources/templates/form/item.html @@ -69,6 +69,17 @@
+ +
+
배송 방식
+ +
+ +
+