「Spring入門」paramsとconsumes/producesの使い方
1. params
@RequestMapping(value = “/demo/{userId}", method = RequestMethod.GET, params="myParam=myValue")
public void findUser(@PathVariable String userId) {
// implementation omitted
}
2.consumes/produces
@Controller
@RequestMapping(value = “/users", method = RequestMethod.POST, consumes="application/json", produces="application/json")
@ResponseBody
public List<User> addUser(@RequestBody User userl) {
// implementation omitted
return List<User> users;
}
3.@RequestMapping(value = “/demo", method = RequestMethod.GET, headers="Referer=http://www.sample.com/")
public void testHeaders(@PathVariable String ownerId, @PathVariable String petId) {
// implementation omitted
}