I\'m using Spring 3.2.0. According to this answer, I have the same method in my annotated controller which implements the HandlerExceptionResolver interface suc
In your ControllerAdvice which is handling the Exception you can have code like this.It worked for me.This is in spring 4.0+
@ExceptionHandler(Exception.class)
public @ResponseBody BaseResponse onException(Exception e, HttpServletResponse response) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
BaseResponse resp = new BaseResponse();
if(e instanceof MaxUploadSizeExceededException){
resp.setCode(FileUploadFailed.SIZE_EXCEED);
resp.setMessage("Maximum upload size exceeded");
}
return resp;
}