October 2017
Intermediate to advanced
396 pages
10h 2m
English
Spring MVC provides one more annotation, @ModelAttributes, for binding data to the Command object. It is another way to bind the data and to customize the data binding. This annotation allows you to control the creation of the Command object. In a Spring MVC application, this annotation can be used on a method and on method arguments. Let's see the following examples:
We can use the ModelAttribute annotation on methods to create an object to be used in our form, as follows:
package com.packt.patterninspring.chapter10.bankapp.web.controller; .... .... @Controller public class AccountController { .... @ModelAttribute public Account account () { return new ...Read now
Unlock full access