Spring @ExceptionHandlerとRedirectAttributes
Spring 4.3.5と5.0 M4以降、
@ExceptionHandler`メソッドで
RedirectAttributes`引数をサポートしています。
@ExceptionHandler(MyCustomException.class)
public String handleError1(MyCustomException e, RedirectAttributes redirectAttributes) {
redirectAttributes.addFlashAttribute("message", "abcdefg");
return "redirect:/viewName";
}
@ExceptionHandler(MultipartException.class)
public String handleError2(MultipartException e, RedirectAttributes redirectAttributes) {
redirectAttributes.addFlashAttribute("message", e.getCause().getMessage());
return "redirect:/viewName";
}
P.Sこのhttps://jira.spring.io/browse/SPR-14651[SPR-14651]
をお読みください