• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between @RequestBody vs @Modelattribute  RSS feed

 
sat kadam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please correct my understanding

@ModelAttribute:
We  want all the form parameters  to  bind with prescribing properties of model object. This is applied at a argument level.
  If we want some common heading for all controller methods then we used @ModelAttribute at method level.

@RequestBody
In case of POST or PUT request and we have  incoming request data in form JSON and want to capture it on server side to initialize the model object.


@modelAttribute to capture form parameters
@RequestBody to capture entire request
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!