「Spring」メディア・タイプ(consumable)を受け入れるサンプル

構文
@PostMapping(path = “xxx", consumes = “application/json")
使用例1

@PostMapping(path = "/users", consumes = "application/json") 
public void addUser(@RequestBody User user) {
    // some code
}

使用例2

@Controller
@RequestMapping(value = "/users", method = RequestMethod.POST, consumes="application/json")
public void addUser(@RequestBody User user, Model model) {
    // some code
}

 

SpringMVC

Posted by arkgame