William Simkins 6 年前
父节点
当前提交
288832c50c

+ 13
- 0
initial/src/main/java/hello/Application.java 查看文件

@@ -0,0 +1,13 @@
1
+package hello;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+
6
+@SpringBootApplication
7
+public class Application {
8
+
9
+    public static void main(String[] args) {
10
+
11
+        SpringApplication.run(Application.class, args);
12
+    }
13
+}

+ 21
- 0
initial/src/main/java/hello/Greeting.java 查看文件

@@ -0,0 +1,21 @@
1
+package hello;
2
+
3
+public class Greeting{
4
+
5
+    private int id;
6
+    private String content;
7
+
8
+    public Greeting(int id, String content){
9
+        this.id = id;
10
+        this.content = content;
11
+    }
12
+
13
+    public String getContent() {
14
+        return content;
15
+    }
16
+    public int getId() {
17
+        return id;
18
+    }
19
+
20
+
21
+}

+ 15
- 0
initial/src/main/java/hello/GreetingController.java 查看文件

@@ -0,0 +1,15 @@
1
+package hello;
2
+
3
+import org.springframework.web.bind.annotation.RequestMapping;
4
+import org.springframework.web.bind.annotation.RequestMethod;
5
+import org.springframework.web.bind.annotation.RequestParam;
6
+import org.springframework.web.bind.annotation.RestController;
7
+
8
+@RestController
9
+public class GreetingController {
10
+
11
+    @RequestMapping(method = RequestMethod.GET, value = "/greeting")
12
+    public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name){
13
+        return new Greeting(1, "Hello " + name);
14
+    }
15
+}