提交 ecc22f71 编写于 作者: J Juergen Hoeller

DispatcherServet.checkMultipart considers MultipartException cause as well

Issue: SPR-15178
上级 7d3fcaa9
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -1091,7 +1091,7 @@ public class DispatcherServlet extends FrameworkServlet {
logger.debug("Request is already a MultipartHttpServletRequest - if not in a forward, " +
"this typically results from an additional MultipartFilter in web.xml");
}
else if (request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE) instanceof MultipartException) {
else if (hasMultipartException(request) ) {
logger.debug("Multipart resolution failed for current request before - " +
"skipping re-resolution for undisturbed error rendering");
}
......@@ -1103,6 +1103,20 @@ public class DispatcherServlet extends FrameworkServlet {
return request;
}
/**
* Check "javax.servlet.error.exception" attribute for a multipart exception.
*/
private boolean hasMultipartException(HttpServletRequest request) {
Throwable error = (Throwable) request.getAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE);
while (error != null) {
if (error instanceof MultipartException) {
return true;
}
error = error.getCause();
}
return false;
}
/**
* Clean up any resources used by the given multipart request (if any).
* @param request current HTTP request
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册