Spring: @ModelAttribute VS @RequestBody
data-binding, spring, spring-mvc
Solution
The simplest way for my understanding is, the `@ModelAttribute` will take a query string. so, all the data are being pass to the server through the url.
As for `@RequestBody`, all the data will be pass to the server through a full JSON body.
Problem
Please correct me if I am wrong. Both can be used for Data Binding. The question is when to use @ModelAttribute? ``` @RequestMapping(value="/owners/{ownerId}/pets/{petId}/edit", method = RequestMethod.POST) public String processSubmit(@ModelAttribute Pet pet) { } ``` In addition, when to use @RequestBody? ``` @RequestMapping(value = "/user/savecontact", method = RequestMethod.POST public String saveContact(@RequestBody Contact contact){ } ``` According to my understanding both serves the similar purpose. Thanks!!