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 @@
-
- - - - - - - -
+ + +