Difference between @RequestBody vs @Modelattribute
posted 3 weeks ago
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