Browse Source

商品初始化

chao 4 years ago
parent
commit
2fa4773ad0

+ 24 - 0
src/main/java/com/caimei/www/controller/HomeController.java

@@ -0,0 +1,24 @@
+package com.caimei.www.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2020/6/15
+ */
+@Controller
+public class HomeController {
+
+	private static final String HOME_PATH = "index";
+
+    @GetMapping("/index.html")
+    public String home(final Model model) {
+        model.addAttribute("msg", "你好666");
+        return HOME_PATH;
+    }
+
+}

+ 8 - 24
src/main/java/com/caimei/www/controller/TestController.java → src/main/java/com/caimei/www/controller/ProductController.java

@@ -16,37 +16,21 @@ import org.thymeleaf.spring5.context.webflux.ReactiveDataDriverContextVariable;
  * @date : 2020/6/12
  * @date : 2020/6/12
  */
  */
 @Controller
 @Controller
-public class TestController {
+public class ProductController {
 
 
-	private static final String INDEX_PATH= "index";
+	private static final String PRODUCT_LIST_PATH = "product/list";
+	private static final String PRODUCT_DETAIL_PATH = "product/detail";
 
 
-    @RequestMapping("/")
-    public String index(final Model model) {
-
-        model.addAttribute("msg", "你好33333333");
-
-        return INDEX_PATH;
-
-    }
-
-
-
-
-
-
-
-
-
-    @GetMapping("/index.html")
+    @GetMapping("/product/list.html")
     public String hello(final Model model) {
     public String hello(final Model model) {
-        model.addAttribute("msg", "你好222222");
-        return INDEX_PATH;
+        model.addAttribute("msg", "商品列表");
+        return PRODUCT_LIST_PATH;
     }
     }
 
 
-    @GetMapping("/product.html")
+    @GetMapping("/product/detail.html")
     public String listPage(final Model model, @RequestParam("pid") Integer productId) {
     public String listPage(final Model model, @RequestParam("pid") Integer productId) {
         model.addAttribute("msg", productId);
         model.addAttribute("msg", productId);
-        return INDEX_PATH;
+        return PRODUCT_DETAIL_PATH;
     }
     }
 
 
 
 

+ 1 - 1
src/main/java/com/caimei/www/controller/RedirectController.java

@@ -15,7 +15,7 @@ public class RedirectController {
 
 
 	@GetMapping("/product-{pid}.html")
 	@GetMapping("/product-{pid}.html")
 	public String toTest(@PathVariable("pid") Integer productId) {
 	public String toTest(@PathVariable("pid") Integer productId) {
-		return "redirect:/product.html?pid=" + productId;
+		return "redirect:/product/detail.html?pid=" + productId;
 	}
 	}
 
 
 }
 }

+ 0 - 0
src/main/resources/templates/common/footer.html → src/main/resources/templates/components/footer.html


+ 0 - 0
src/main/resources/templates/common/header.html → src/main/resources/templates/components/header.html


+ 2 - 2
src/main/resources/templates/index.html

@@ -9,12 +9,12 @@
 </head>
 </head>
 <body>
 <body>
     <!-- 引用头部 -->
     <!-- 引用头部 -->
-    <div th:replace="common/header"></div>
+    <div th:replace="components/header"></div>
     <div class="container">
     <div class="container">
         欢迎
         欢迎
         <p th:text="${msg}"></p>
         <p th:text="${msg}"></p>
     </div>
     </div>
     <!-- 引入底部 -->
     <!-- 引入底部 -->
-    <div th:replace="common/footer"></div>
+    <div th:replace="components/footer"></div>
 </body>
 </body>
 </html>
 </html>

+ 20 - 0
src/main/resources/templates/product/detail.html

@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="https://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport"
+          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+    <meta http-equiv="X-UA-Compatible" content="ie=edge">
+    <title>Document</title>
+</head>
+<body>
+    <!-- 引用头部 -->
+    <div th:replace="components/header"></div>
+    <div class="container">
+        商品详情
+        <p th:text="${msg}"></p>
+    </div>
+    <!-- 引入底部 -->
+    <div th:replace="components/footer"></div>
+</body>
+</html>

+ 21 - 0
src/main/resources/templates/product/list.html

@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="https://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport"
+          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+    <meta http-equiv="X-UA-Compatible" content="ie=edge">
+    <title>Document</title>
+</head>
+<body>
+    <!-- 引用头部 -->
+    <div th:replace="components/header"></div>
+    <div class="container">
+        商品列表
+        <p th:text="${msg}"></p>
+    </div>
+    <!-- 引入底部 -->
+    <!-- 引入底部 -->
+    <div th:replace="components/footer"></div>
+</body>
+</html>