Last active
March 7, 2016 18:23
-
-
Save MafaldaLandeiro/98c6d29a60c8bdf03804 to your computer and use it in GitHub Desktop.
Greeting controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.SpringRestfulService.controller; | |
| import java.util.Date; | |
| import org.SpringRestfulService.reply.Greeting; | |
| import org.springframework.web.bind.annotation.RequestMapping; | |
| import org.springframework.web.bind.annotation.RequestParam; | |
| import org.springframework.web.bind.annotation.RestController; | |
| @RestController | |
| public class GreetingController { | |
| private static final String templateGreeting = "Hello, %s!"; | |
| private final Date date = new Date(); | |
| @RequestMapping("/getGreeting") | |
| public Greeting getGreeting(@RequestParam(value="name",defaultValue="everyone")String name){ | |
| return new Greeting(date.toString(), String.format(templateGreeting, name)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment