Tôi muốn sử dụng RedirectAttibutes tài sản đó đã đưa ra trong mùa xuân 3.1, tôi có các phương pháp xử lý sau đây cho bài trong bộ điều khiển của tôiRedirectAttributes cho IllegalStateException trong mùa xuân 3,1
@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";
}
Nhưng khi tôi nộp mẫu đơn I đang nhận được ngoại lệ sau:
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)
Tôi đã gặp một vài lỗi với chuyển hướngThuộc tính mà bạn không thể sử dụng ModelAndView làm loại trả về. Vì vậy, tôi trở lại chỉ xem chuỗi.
Bất kỳ ai có thể pl. cho tôi biết tôi đang đi sai ở đâu?
Cảm ơn.
Thêm đã giải quyết được sự cố !!! Cảm ơn. –
tintin
@EnableWebMvc dành cho trình điều khiển đã giải quyết được sự cố. Bạn nên thêm "mvc: định hướng chú thích" ở đâu? –