diff --git a/src/main/java/com/example/demo/controller/TestController.java b/src/main/java/com/example/demo/controller/TestController.java index 5bc4a1d0ba39ff9d72bd5d682759a843df4cdb2e..67559cd81979a636ff2912caa56239d2f426da07 100644 --- a/src/main/java/com/example/demo/controller/TestController.java +++ b/src/main/java/com/example/demo/controller/TestController.java @@ -15,16 +15,13 @@ public class TestController { public String test(@RequestParam("id") String id){ JsonObject obj = new JsonObject(); - obj.addProperty("title", "산사와 아가싸"); - obj.addProperty("content", "로맨틱 코메디"); - - JsonObject data = new JsonObject(); - data.addProperty("time", "토일 8시"); - obj.add("data", data); + obj.addProperty("item_nm", "수제 햄버거"); + obj.addProperty("item_detail", "소고기 패티와 토마토가 들어 있는 햄버거"); + obj.addProperty("item_reg_date", "2022/04/22"); + obj.addProperty("item_price", "4000"); return obj.toString(); } - } diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index e534d270a334697f061227814f9a7a02598a6e9f..8d5a599423158a82ae63466b3e981ce24df777d8 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -31,7 +31,7 @@ <tr> <td>COM001</td> <td>REG02</td> - <td>커뮤니티 등록/td> + <td>커뮤니티 등록</td> <td>커뮤니티 등록</td> </tr> </tbody> diff --git a/src/main/resources/static/product.html b/src/main/resources/static/product.html new file mode 100644 index 0000000000000000000000000000000000000000..f413bc806e7dbe4ea17fffb2d978504abcbb4530 --- /dev/null +++ b/src/main/resources/static/product.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>Product</title> + <link rel="stylesheet" href="/webjars/bootstrap/5.1.3/css/bootstrap.min.css"> + <script src="/webjars/jquery/3.6.0/jquery.min.js"></script> + <script src="/webjars/popper.js/2.9.3/umd/popper.min.js"></script> + <script src="/webjars/bootstrap/5.1.3/js/bootstrap.min.js"></script> + <script> + $(document).ready(function(){ + $("button").click(function(){ + + $.ajax({ + + type: 'GET', + url: '/test?id=1', + success: function(data){ + var obj = JSON.parse(data); + $('#item_nm span').text(obj.item_nm) + $('#item_detail span').text(obj.item_detail) + $('#item_reg_date span').text(obj.item_reg_date) + $('#item_price span').text(obj.item_price) + } + + }); + + + }); + }); + </script> + +</head> +<body> + <h1>상품 데이터 출력 예제</h1> + <div id = "item_nm">상품명: <span></span></div> + <div id = "item_detail">상품 상세설명: <span></span></div> + <div id = "item_reg_date">상품 등록일: <span></span></div> + <div id = "item_price">삼품가격: <span></span></div> + <button>조회</button> +</body> +</html>