Q: @ExceptionHandler method not redirect to return view 
i have a problem with @ExceptionHandler method in @ControllerAdvice
My method is invoked when exception is occur but never rediret to the site returning by this method. I was try to return ModelANdView, RedirectView or String but it never work correct
this is actual code my method:
public static final String REFERER_HEADER = "Referer";
public static final String REDIRECT = "redirect:";    

@ExceptionHandler(value = MaxUploadSizeExceededException.class)
public RedirectView maxUploadSizeExceededExceptionHandler(MaxUploadSizeExceededException e,
                                                          HttpServletRequest request,HttpServletResponse response) {

    String sourcePage = request.getHeader(REFERER_HEADER);
    RedirectView rw = new RedirectView(REDIRECT + sourcePage);
    return rw;
}

but as i say that not redirect correct. In browser i stay on page when exception in occur

A: Can you try with either one of them ...
public static final String REFERER_HEADER = "Referer";
public static final String FORWARD_PREFIX = "forward:";    

@ExceptionHandler(value = MaxUploadSizeExceededException.class)
public String maxUploadSizeExceededExceptionHandler(MaxUploadSizeExceededException e,
                                                      HttpServletRequest request,HttpServletResponse response) {

  String sourcePage = request.getHeader(REFERER_HEADER); // Assuming you have sourcePage eg : "/pageURL"
  return FORWARD_PREFIX + sourcePage;
}

OR
public static final String REFERER_HEADER = "Referer";

@ExceptionHandler(value = MaxUploadSizeExceededException.class)
public ModelAndView maxUploadSizeExceededExceptionHandler(MaxUploadSizeExceededException e,
                                                  HttpServletRequest request,HttpServletResponse response) {

  String sourcePage = request.getHeader(REFERER_HEADER);
  final RedirectView rv = new RedirectView(sourcePage);
  rv.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
  rv.setUrl(sourcePage);
  final ModelAndView mv = new ModelAndView(rv);
  return mv;
}

But I am not sure...
