From 32c31251687acd24af05d84ce729a2ad8cd96be2 Mon Sep 17 00:00:00 2001
From: EuichanJeong <dmlcks5791@ajou.ac.kr>
Date: Wed, 2 Apr 2025 17:37:00 +0900
Subject: [PATCH] add product.html

---
 .../demo/controller/TestController.java       | 11 ++---
 src/main/resources/static/index.html          |  2 +-
 src/main/resources/static/product.html        | 42 +++++++++++++++++++
 3 files changed, 47 insertions(+), 8 deletions(-)
 create mode 100644 src/main/resources/static/product.html

diff --git a/src/main/java/com/example/demo/controller/TestController.java b/src/main/java/com/example/demo/controller/TestController.java
index 5bc4a1d..67559cd 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 e534d27..8d5a599 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 0000000..f413bc8
--- /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>
-- 
GitLab