Spring: @ModelAttribute VS @RequestBody -


Please correct me if I am wrong Data binding both can be used .

The question is when the @Model Attribute is used? @RequestMapping (value = "/ owner / {OwnerId} / pet / {petId} / edit", method = RequestMethod.POST) Public String Process Submit (@ModelAttribute Pet pet) { }

Additionally, when using @RequestBody?

  @RequestMapping (value = "/ user / saved contact", method = RequestMethod.POST public string save communication (@RequestBody contact contact) {}   

According to my understanding both do the same purpose.

Thanks!

Simple The way to my understanding, the @ Model Attribute will take a query string, so all the data is being passed through the URL via the URL.

@ RequestBody < / Code>, all data complete JSON Will be passed to the server through Odi.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -