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