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

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -