「Spring」メディア・タイプ(producible)を生成するサンプル
構文
@GetMapping(path = “xxx", produces = “application/json")
使用例1
@GetMapping(path = "/users/{userId}", produces = "application/json")
@ResponseBody
public Pet getUser(@PathVariable String userId) {
// some code
}
使用例2
@RequestMapping(value = "/users/{userId}", method = RequestMethod.GET, produces="application/json")
@ResponseBody
public Pet getUser(@PathVariable String userId, Model model) {
// some code
}