Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between @RequestBody vs @Modelattribute  RSS feed

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

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.

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
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!