From 01a1421e9fc46f67758922795ad7e6cc195a9a03 Mon Sep 17 00:00:00 2001 From: Allensharp <1561946958@qq.com> Date: Thu, 15 Jul 2021 16:09:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BA=86=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/swpu/controller/JavaSpringBootController.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/swpu/controller/JavaSpringBootController.java b/src/main/java/com/swpu/controller/JavaSpringBootController.java index d584d5a..321d2df 100644 --- a/src/main/java/com/swpu/controller/JavaSpringBootController.java +++ b/src/main/java/com/swpu/controller/JavaSpringBootController.java @@ -23,10 +23,9 @@ public class JavaSpringBootController { * @return object */ @GetMapping(value = "/find") - public Object add(@RequestParam(value = "x") int x, @RequestParam(value = "y") int a, - @RequestParam(value = "z") int z) { - var y = (x + a) * z; - return "计算结果为: " + y; + public Object add(@RequestParam("x") int x) { + var y = 1 + x; + return y + " Hello Get"; } /** @@ -35,8 +34,8 @@ public class JavaSpringBootController { * @return object */ @PostMapping(value = "/insert") - public Object test() { - return "Hello Post !"; + public Object test(@RequestParam("name") String name) { + return "I am"+name; } /** -- Gitee From b02099c6a71e4bd3bd862ec92fecf36e65aaf36e Mon Sep 17 00:00:00 2001 From: Allensharp <1561946958@qq.com> Date: Thu, 15 Jul 2021 16:26:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BA=86=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JavaSpringBootController.java | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 JavaSpringBootController.java diff --git a/JavaSpringBootController.java b/JavaSpringBootController.java new file mode 100644 index 0000000..ffba345 --- /dev/null +++ b/JavaSpringBootController.java @@ -0,0 +1,61 @@ +package com.swpu.controller; + +import org.springframework.web.bind.annotation.*; + +/** + * @author wales + *

+ * Spring Boot Controller 接口开发基础 + * + *

+ */ +@RestController +@RequestMapping(value = "/login") +public class JavaSpringBootController { + + /** + * GetMapping - 代表着当前的方法只能通过 GET 请求来访问 http://localhost:8080/login/find + * + * @return object + */ + @GetMapping(value = "/find") + public Object add(@RequestParam("x") int x) { + var y = 1 + x; + return y + " Hello Get"; + } + + /** + * PostMapping - 代表着当前的方法只能通过 POST 请求来访问 http://localhost:8080/login/insert + * + * @return object + */ + @PostMapping(value = "/insert") + public Object test() { + return "Hello Post !"; + } + + /** + * PutMapping - 代表着当前的方法只能通过 PUT 请求来访问 http://localhost:8080/login/update + * + * @return object + */ + @PutMapping(value = "/update") + public Object update() { + return "Hello Update !"; + } + + /** + * DeleteMapping - 代表着当前的方法只能通过 DELETE 请求来访问 http://localhost:8080/login/delete + * + * @return object + */ + @DeleteMapping(value = "/delete") + public Object delete() { + return "Hello Delete"; + } + +} -- Gitee From dec63ef540c52ff855298593558c01e0fef74482 Mon Sep 17 00:00:00 2001 From: Allensharp <1561946958@qq.com> Date: Thu, 15 Jul 2021 16:37:48 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BA=86=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/swpu/controller/JavaSpringBootController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/swpu/controller/JavaSpringBootController.java b/src/main/java/com/swpu/controller/JavaSpringBootController.java index 321d2df..6787b87 100644 --- a/src/main/java/com/swpu/controller/JavaSpringBootController.java +++ b/src/main/java/com/swpu/controller/JavaSpringBootController.java @@ -28,13 +28,14 @@ public class JavaSpringBootController { return y + " Hello Get"; } + /** * PostMapping - 代表着当前的方法只能通过 POST 请求来访问 http://localhost:8080/login/insert * * @return object */ @PostMapping(value = "/insert") - public Object test(@RequestParam("name") String name) { + public Object insert(@RequestParam("name") String name) { return "I am"+name; } -- Gitee