「Spring」@RequestBodyでJSONを受け取る方法
書式
@RequestBody クラス名 変数名
使用例
@RestController
public class UserController {
public static class UserBean {
public String username;
public int age;
}
//JSONを受け取る
@RequestMapping(path = "/example/opdata", method = RequestMethod.POST)
public String opdata(@RequestBody UserBean userBean) {
//処理コード
return "success";
}
}