I am trying to send 'user' object to another controller but the method rattr.addAttribute("user",user) is giving error as below
Resolved [org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type 'com.company.models.User' to required type 'java.lang.String'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'com.company.models.User' to required type 'java.lang.String': no matching editors or conversion strategy found]
Code:
public String Register(@Valid @ModelAttribute("user") User user,Errors errors,Model model,HttpServletRequest request, RedirectAttributes rattrs) {
if(errors.hasErrors()) {
return "user";
}
else {
// RegisterService.show(user);
xes.export(user);
request.setAttribute("user", user);
request.getAttribute("user");
System.out.println(" console prints till here");
rattrs.addAttribute("user", user);
return "redirect:/success";
}
}
How can I send user object through redirect to success page?