reset password
Author Message
tonyg
Posts: 11
Posted 16:14 Feb 19, 2015 |

Spring provides tags for binding an object's fields to an input tag, if that object is passed to a view using a ModelMap. It makes sense for the form tags to only send the data for fields included in the form. For example, if I want to change two fields of an object that has 10 fields, I put 2 input tags in the form, and only those two values in the form are sent in the get request.

 

However, when using the @ModelAttribute annotation in the controller that processes the form, the object being returned only has the fields that were sent from the form (2 fields instead of 10). Why are the other fields set to null? Is there a way to access all of the original fields without querying the database using a DAO method?

cysun
Posts: 2935
Posted 16:34 Feb 19, 2015 |

It this the reason why we use @SessionAttribute?