@ModelAttribute

From NovaOrdis Knowledge Base
Revision as of 00:02, 15 October 2018 by Ovidiu (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

@ModelAttribute ensures that the corresponding object will be created in the model.

public class ...Controller {

    @ModelAttribute(name = "something")
    public Something something() {
        return new Something();
    }

When attached to a controller method argument, indicates that the value should come from the model and that Spring MVC should not attempt to bind request parameters to it.