Skip to content

Instantly share code, notes, and snippets.

@MafaldaLandeiro
Last active March 7, 2016 18:23
Show Gist options
  • Select an option

  • Save MafaldaLandeiro/98c6d29a60c8bdf03804 to your computer and use it in GitHub Desktop.

Select an option

Save MafaldaLandeiro/98c6d29a60c8bdf03804 to your computer and use it in GitHub Desktop.
Greeting controller
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