GlobalExceptionHandler.java 731 B

1234567891011121314151617181920
  1. package com.neo.controller;
  2. import org.springframework.web.bind.annotation.ControllerAdvice;
  3. import org.springframework.web.bind.annotation.ExceptionHandler;
  4. import org.springframework.web.multipart.MultipartException;
  5. import org.springframework.web.servlet.mvc.support.RedirectAttributes;
  6. @ControllerAdvice
  7. public class GlobalExceptionHandler {
  8. //https://jira.spring.io/browse/SPR-14651
  9. //4.3.5 supports RedirectAttributes redirectAttributes
  10. @ExceptionHandler(MultipartException.class)
  11. public String handleError1(MultipartException e, RedirectAttributes redirectAttributes) {
  12. redirectAttributes.addFlashAttribute("message", e.getCause().getMessage());
  13. return "redirect:/uploadStatus";
  14. }
  15. }