@ModelAttribute: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Spring MVC Concepts =Overview= <syntaxhighlight lang='java'> public class ...Controller { @ModelAttribute(n...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Internal=
=Internal=


* [[Spring_MVC_Concepts#Controller_Annotations|Spring MVC Concepts]]
* [[Spring_MVC_Concepts#Controller_Annotations|Controller]]
* [[Spring_MVC_Concepts#Model|Model]]


=Overview=
=Overview=
@ModelAttribute ensures that the corresponding object will be created in the [[Spring MVC Concepts#Model|model]].


<syntaxhighlight lang='java'>
<syntaxhighlight lang='java'>
Line 14: Line 17:


</syntaxhighlight>
</syntaxhighlight>
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.

Latest revision as of 00:02, 15 October 2018

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.