Tags

links:
http://www.programming-free.com/2014/01/spring-mvc-40-restful-web-services.html
http://www.beabetterdeveloper.com/2013/07/spring-mvc-requestbody-and-responsebody.html
http://stackoverflow.com/questions/18189245/how-to-set-the-default-content-type-in-spring-mvc-in-no-accept-header-is-provide (default media)

summary:
– spring mvc 3.0 vs 4.0

 
// spring mvc 4.0
@RestController
@RequestMapping("/service/greeting")
public class SpringServiceController {
 @RequestMapping(value = "/{name}", method = RequestMethod.GET)
 public String getGreeting(@PathVariable String name) {
  String result="Hello "+name;  
  return result;
 }
}
// spring mvc 3.0
@Controller
@RequestMapping("/service/greeting")
public class SpringServiceController {
 @RequestMapping(value = "/{name}", method = RequestMethod.GET)
 public @ResponseBody String getGreeting(@PathVariable String name) {
  String result="Hello "+name;  
  return result;
 }
}
Advertisements