Bladeren bron

PLayed around with spring

Raymond Farria 6 jaren geleden
bovenliggende
commit
f89d2122cc
3 gewijzigde bestanden met toevoegingen van 13 en 4 verwijderingen
  1. 1
    1
      complete/src/main/java/hello/Greeting.java
  2. 11
    3
      complete/src/main/java/hello/GreetingController.java
  3. 1
    0
      test/run.sh

+ 1
- 1
complete/src/main/java/hello/Greeting.java Bestand weergeven

@@ -1,4 +1,4 @@
1
-package hello;
1
+package main.java.hello;
2 2
 
3 3
 public class Greeting {
4 4
 

+ 11
- 3
complete/src/main/java/hello/GreetingController.java Bestand weergeven

@@ -1,10 +1,12 @@
1 1
 package hello;
2 2
 
3
-import java.util.concurrent.atomic.AtomicLong;
3
+import main.java.hello.Greeting;
4 4
 import org.springframework.web.bind.annotation.RequestMapping;
5 5
 import org.springframework.web.bind.annotation.RequestParam;
6 6
 import org.springframework.web.bind.annotation.RestController;
7 7
 
8
+import java.util.concurrent.atomic.AtomicLong;
9
+
8 10
 @RestController
9 11
 public class GreetingController {
10 12
 
@@ -12,8 +14,14 @@ public class GreetingController {
12 14
     private final AtomicLong counter = new AtomicLong();
13 15
 
14 16
     @RequestMapping("/greeting")
15
-    public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
16
-        return new Greeting(counter.incrementAndGet(),
17
+    public main.java.hello.Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
18
+        return new main.java.hello.Greeting(counter.incrementAndGet(),
17 19
                             String.format(template, name));
18 20
     }
21
+
22
+    @RequestMapping("/greeting?name=User")
23
+    public main.java.hello.Greeting anothergreeting(@RequestParam(value = "name", defaultValue = "User")String name){
24
+        return new Greeting(counter.incrementAndGet(),
25
+                            String.format(template,name));
26
+    }
19 27
 }

+ 1
- 0
test/run.sh Bestand weergeven

@@ -1,3 +1,4 @@
1
+#!/usr/bin/env bash
1 2
 cd $(dirname $0)
2 3
 cd ../initial
3 4