|
@@ -1,21 +1,19 @@
|
1
|
1
|
package hello;
|
2
|
2
|
|
3
|
3
|
import java.util.concurrent.atomic.AtomicLong;
|
4
|
|
-import org.springframework.stereotype.Controller;
|
5
|
4
|
import org.springframework.web.bind.annotation.RequestMapping;
|
6
|
5
|
import org.springframework.web.bind.annotation.RequestParam;
|
7
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
6
|
+import org.springframework.web.bind.annotation.RestController;
|
8
|
7
|
|
9
|
|
-@Controller
|
|
8
|
+@RestController
|
10
|
9
|
public class GreetingController {
|
11
|
10
|
|
12
|
11
|
private static final String template = "Hello, %s!";
|
13
|
12
|
private final AtomicLong counter = new AtomicLong();
|
14
|
13
|
|
15
|
14
|
@RequestMapping("/greeting")
|
16
|
|
- public @ResponseBody Greeting greeting(
|
17
|
|
- @RequestParam(value="name", required=false, defaultValue="World") String name) {
|
|
15
|
+ public Greeting greeting(@RequestParam(value="name", required=false, defaultValue="World") String name) {
|
18
|
16
|
return new Greeting(counter.incrementAndGet(),
|
19
|
17
|
String.format(template, name));
|
20
|
18
|
}
|
21
|
|
-}
|
|
19
|
+}
|