I want to use the RedirectAttibutes property introduced in Spring 3.1, I have the following handler method for the message in my controller
@RequestMapping(value = "/register", method = RequestMethod.POST)
public String register(@ModelAttribute("admin") Admin admin, BindingResult bindingResult, SessionStatus sessionStatus, RedirectAttributes redirectAttributes) {
redirectAttributes.addAttribute("admin", admin);
if (bindingResult.hasErrors()) {
return REGISTRATION_VIEW;
}
sessionStatus.setComplete();
return "redirect:list";
}
But when I submit the form, I get the following exception:
java.lang.IllegalStateException: Argument [RedirectAttributes] is of type Model or Map but is not assignable from the actual model. You may need to switch newer MVC infrastructure classes to use this argument.
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:322)
I came across several gotcha with redirectAttributes that cannot use ModelAndView as return type. Therefore, I returned only the representation of the string.
Can anyone pl. tell me where am i wrong
Thank.
source
share