LoginSignup
0
2

More than 5 years have passed since last update.

curl コマンドでJSONの値を渡す方法(@RequestBody)

Last updated at Posted at 2018-10-18

@RequestBodyで指定した変数にcurlコマンドでJSONの値を渡す方法

環境 Mac
注) win環境においては、JSONファイルを別で作り読み込む方法だとうまく行くと思います。

java側

 @RequestMapping(value="/post",method=RequestMethod.POST)
  public Person getPerson(@RequestBody Person person){
        return service.saveAndFlush(person);

  }

コマンド

curl -X POST -H "Content-Type: application/json" -d '{"id":"1","name":"nameuser","age":"10"}' localhost:8080/person/post
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2