Navya Sanal před 6 roky
rodič
revize
461ec823cb

+ 22
- 0
initial/src/main/java/hello/Greeting.java Zobrazit soubor

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

+ 19
- 0
initial/src/main/java/hello/GreetingControl.java Zobrazit soubor

@@ -0,0 +1,19 @@
1
+package hello;
2
+
3
+import java.util.concurrent.atomic.AtomicLong;
4
+import org.springframework.web.bind.annotation.RequestMapping;
5
+import org.springframework.web.bind.annotation.RequestParam;
6
+import org.springframework.web.bind.annotation.RestController;
7
+@RestController
8
+class GreetingController {
9
+    private static final String template = "Hello, %s!";
10
+    private final AtomicLong counter = new AtomicLong();
11
+    @RequestMapping("/greeting")//BY Default get
12
+    public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
13
+        return new Greeting(counter.incrementAndGet(), String.format(template, name));
14
+
15
+        // returns a new Greeting object with id and content attributes based on the next value from the counter
16
+                //String.format(template, name);//and formats the given name by using the greeting template
17
+    }
18
+}
19
+

+ 16
- 0
initial/src/main/java/hello/MainApplication.java Zobrazit soubor

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