List of usage examples for org.springframework.web.multipart MultipartException getRootCause
@Nullable
public Throwable getRootCause()
From source file:com.devnexus.ting.web.controller.SiteController.java
@RequestMapping("/s/handleGlobaleErrors") public String onUploadError(HttpServletRequest request, final Model model, RedirectAttributes redirectAttributes) { final Object errorExceptionObject = request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE); if (errorExceptionObject instanceof MultipartException) { final MultipartException multipartException = (MultipartException) errorExceptionObject; final Throwable rootCause = multipartException.getRootCause(); String errorMessage = ""; if (rootCause instanceof SizeLimitExceededException || rootCause instanceof FileSizeLimitExceededException) { errorMessage = String.format( "The file that you are trying to upload is unfortunately too big. Uploaded files cannot be bigger than <strong>%s</strong>." + " Please go back and upload a smaller image file.", multipartProperties.getMaxFileSize()); } else {//from w ww . ja va2 s . c om errorMessage = (String) request.getAttribute(WebUtils.ERROR_MESSAGE_ATTRIBUTE); } redirectAttributes.addFlashAttribute("error", errorMessage); return "redirect:/s/uploadError"; } else { return "error/error"; } }