i am new Spring learner.i'm really confused about what is the difference between two concept:
- @ModelAttribute
- model.addAttribute
in below there are two "user" value.Are these same thing?Why should I use like this? Thank you all
@RequestMapping(method = RequestMethod.GET)
public String setupForm(ModelMap model) {
model.addAttribute("user", new User());
return "editUser";
}
@RequestMapping(method = RequestMethod.POST)
public String processSubmit( @ModelAttribute("user") User user, BindingResult result, SessionStatus status) {
userStorageDao.save(user);
status.setComplete();
return "redirect:users.htm";
}