I have something like
@RequestMapping("/showRegister")
public String showUserRegistrationForm(ModelMap modelMap) {
modelMap.addAttribute("user", new UserBean());
return "Register";
}
@RequestMapping("/RegisterUser")
public String registerUser(@ModelAttribute("user") UserBean userBean,
BindingResult result, ModelMap modelMap) {
System.out.println(userBean.getPassword());
return "Register";
}
in my code.
The above works perfectly. Now suppose I want to save the modal data from form into multiple tables each having its own POJO Class. So how would the code be so as to receive not just UserBean as modelattribute but also other classes. Will I have to create a new POJO containing data from both the classes or is there a other way around.
EDIT
I read about DTO. But doesn't it make a repetition of POJO's. Can't we use a mix of 2-3 POJO's instead.