use of org.springframework.web.multipart.MaxUploadSizeExceededException in project spring-framework by spring-projects.
the class CommonsMultipartResolver method parseRequest.
/**
* Parse the given servlet request, resolving its multipart elements.
* @param request the request to parse
* @return the parsing result
* @throws MultipartException if multipart resolution failed.
*/
protected MultipartParsingResult parseRequest(HttpServletRequest request) throws MultipartException {
String encoding = determineEncoding(request);
FileUpload fileUpload = prepareFileUpload(encoding);
try {
List<FileItem> fileItems = ((ServletFileUpload) fileUpload).parseRequest(request);
return parseFileItems(fileItems, encoding);
} catch (FileUploadBase.SizeLimitExceededException ex) {
throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
} catch (FileUploadBase.FileSizeLimitExceededException ex) {
throw new MaxUploadSizeExceededException(fileUpload.getFileSizeMax(), ex);
} catch (FileUploadException ex) {
throw new MultipartException("Failed to parse multipart servlet request", ex);
}
}
use of org.springframework.web.multipart.MaxUploadSizeExceededException in project head by mifos.
the class UncaughtExceptionHandler method checkForMaxUploadSizeExceededException.
private ModelAndView checkForMaxUploadSizeExceededException(Exception ex, HttpServletRequest request) {
if (ex instanceof MaxUploadSizeExceededException) {
ModelAndView modelAndView = null;
String viewName = determineViewName(ex, request);
if (viewName != null) {
modelAndView = getModelAndView(viewName, ex, request);
}
return modelAndView;
}
return null;
}
use of org.springframework.web.multipart.MaxUploadSizeExceededException in project spring-framework by spring-projects.
the class DispatcherServletTests method multipartResolutionFailed.
@Test
public void multipartResolutionFailed() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest(getServletContext(), "GET", "/locale.do;abc=def");
request.addPreferredLocale(Locale.CANADA);
request.addUserRole("role1");
request.setAttribute("fail", Boolean.TRUE);
MockHttpServletResponse response = new MockHttpServletResponse();
complexDispatcherServlet.service(request, response);
assertTrue("forwarded to failed", "failed0.jsp".equals(response.getForwardedUrl()));
assertEquals(200, response.getStatus());
assertTrue("correct exception", request.getAttribute(SimpleMappingExceptionResolver.DEFAULT_EXCEPTION_ATTRIBUTE) instanceof MaxUploadSizeExceededException);
}
Aggregations