@ExceptionHandler(MultipartException.class) public String handleError1(MultipartException e, RedirectAttributes redirectAttributes) { redirectAttributes.addFlashAttribute("message", e.getCause().getMessage()); return "redirect:/uploadStatus"; } }
/*** * 全局的统一MultipartException异常处理,当上传文件超过设定最大值,错误信息显示在页面 * @param e * @param redirectAttributes * @return */ @ExceptionHandler(MultipartException.class) public String multipartException(MultipartException e, RedirectAttributes redirectAttributes){ redirectAttributes.addFlashAttribute("message",e.getCause().getMessage()); return "redirect:uploadShow"; } }