From 5440d3c5258c5d59cb7a551ea8cc24e1c2719940 Mon Sep 17 00:00:00 2001 From: daniel LEE Date: Fri, 27 Oct 2023 10:32:37 +0900 Subject: [PATCH] =?UTF-8?q?=ED=99=94=EB=A9=B4=EC=97=90=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=83=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/JSPController.java | 17 +- src/main/webapp/WEB-INF/views/index.jsp | 209 ++---------------- 2 files changed, 30 insertions(+), 196 deletions(-) diff --git a/src/main/java/com/example/demo/controller/JSPController.java b/src/main/java/com/example/demo/controller/JSPController.java index c7e1fc3..df71280 100644 --- a/src/main/java/com/example/demo/controller/JSPController.java +++ b/src/main/java/com/example/demo/controller/JSPController.java @@ -34,12 +34,21 @@ public class JSPController { @GetMapping("/index.do") public String index(Model model) { + ResponseEntity result = callForecastApi(); + JSONObject json = new JSONObject(result); + JSONArray jsonArr = new JSONArray( json.get("body").toString() ); + List list = new ArrayList(); - for ( int i = 0; i < 8; i++) { - HashMap map = new HashMap(); - map.put( "filepath", "/img/52e11fb7-f206-48d8-b13d-e010e852fd6a.jpeg" ); + for ( int i = 0; i < jsonArr.length(); i++) { + HashMap map = new HashMap(); + JSONObject obj = jsonArr.getJSONObject(i); + map.put( "id", obj.getString("phone") ); + map.put( "name", obj.getString("name") ); + map.put( "phone", obj.getString("phone") ); + map.put( "address", obj.getString("address") ); + map.put( "filepath", obj.getString("filepath") ); list.add(map); - } + } model.addAttribute("list", list); diff --git a/src/main/webapp/WEB-INF/views/index.jsp b/src/main/webapp/WEB-INF/views/index.jsp index 4ed1589..0830048 100644 --- a/src/main/webapp/WEB-INF/views/index.jsp +++ b/src/main/webapp/WEB-INF/views/index.jsp @@ -58,22 +58,28 @@
- - - - - + + +
- ... + ...
-
Fancy Product
+
${ item.name }
- $40.00 - $80.00 + ${ item.phone } +
+ + +
+
+ +
+
@@ -81,191 +87,10 @@
-
- - - - - - - -
+ + +