MissingServletRequestPartException extends ServletRequestBindingException
Closes gh-27948
This commit is contained in:
parent
303e363adf
commit
ad2722b3a3
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -16,8 +16,7 @@
|
|||
|
||||
package org.springframework.web.multipart.support;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
|
||||
import org.springframework.web.bind.ServletRequestBindingException;
|
||||
import org.springframework.web.multipart.MultipartResolver;
|
||||
|
||||
/**
|
||||
|
@ -30,10 +29,11 @@ import org.springframework.web.multipart.MultipartResolver;
|
|||
* e.g. no {@link MultipartResolver}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Wonchul Heo
|
||||
* @since 3.1
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MissingServletRequestPartException extends ServletException {
|
||||
public class MissingServletRequestPartException extends ServletRequestBindingException {
|
||||
|
||||
private final String requestPartName;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -73,6 +73,7 @@ import org.springframework.web.util.WebUtils;
|
|||
* detected, {@link ExceptionHandlerExceptionResolver} must be configured.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Wonchul Heo
|
||||
* @since 3.2
|
||||
* @see #handleException(Exception, WebRequest)
|
||||
* @see org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver
|
||||
|
@ -108,13 +109,13 @@ public abstract class ResponseEntityExceptionHandler {
|
|||
HttpMediaTypeNotAcceptableException.class,
|
||||
MissingPathVariableException.class,
|
||||
MissingServletRequestParameterException.class,
|
||||
MissingServletRequestPartException.class,
|
||||
ServletRequestBindingException.class,
|
||||
ConversionNotSupportedException.class,
|
||||
TypeMismatchException.class,
|
||||
HttpMessageNotReadableException.class,
|
||||
HttpMessageNotWritableException.class,
|
||||
MethodArgumentNotValidException.class,
|
||||
MissingServletRequestPartException.class,
|
||||
BindException.class,
|
||||
NoHandlerFoundException.class,
|
||||
AsyncRequestTimeoutException.class
|
||||
|
@ -143,6 +144,10 @@ public abstract class ResponseEntityExceptionHandler {
|
|||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||
return handleMissingServletRequestParameter((MissingServletRequestParameterException) ex, headers, status, request);
|
||||
}
|
||||
else if (ex instanceof MissingServletRequestPartException) {
|
||||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||
return handleMissingServletRequestPart((MissingServletRequestPartException) ex, headers, status, request);
|
||||
}
|
||||
else if (ex instanceof ServletRequestBindingException) {
|
||||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||
return handleServletRequestBindingException((ServletRequestBindingException) ex, headers, status, request);
|
||||
|
@ -167,10 +172,6 @@ public abstract class ResponseEntityExceptionHandler {
|
|||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||
return handleMethodArgumentNotValid((MethodArgumentNotValidException) ex, headers, status, request);
|
||||
}
|
||||
else if (ex instanceof MissingServletRequestPartException) {
|
||||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||
return handleMissingServletRequestPart((MissingServletRequestPartException) ex, headers, status, request);
|
||||
}
|
||||
else if (ex instanceof BindException) {
|
||||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||
return handleBindException((BindException) ex, headers, status, request);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
|
@ -90,6 +90,10 @@ import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
|
|||
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
||||
* </tr>
|
||||
* <tr class="rowColor">
|
||||
* <td><p>MissingServletRequestPartException</p></td>
|
||||
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
||||
* </tr>
|
||||
* <tr class="rowColor">
|
||||
* <td><p>ServletRequestBindingException</p></td>
|
||||
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
||||
* </tr>
|
||||
|
@ -113,10 +117,6 @@ import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
|
|||
* <td><p>MethodArgumentNotValidException</p></td>
|
||||
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
||||
* </tr>
|
||||
* <tr class="rowColor">
|
||||
* <td><p>MissingServletRequestPartException</p></td>
|
||||
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
||||
* </tr>
|
||||
* <tr class="altColor">
|
||||
* <td><p>BindException</p></td>
|
||||
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
||||
|
@ -135,6 +135,7 @@ import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
|
|||
* @author Arjen Poutsma
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
* @author Wonchul Heo
|
||||
* @since 3.0
|
||||
* @see org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
|
||||
*/
|
||||
|
@ -188,6 +189,10 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
|
|||
return handleMissingServletRequestParameter(
|
||||
(MissingServletRequestParameterException) ex, request, response, handler);
|
||||
}
|
||||
else if (ex instanceof MissingServletRequestPartException) {
|
||||
return handleMissingServletRequestPartException(
|
||||
(MissingServletRequestPartException) ex, request, response, handler);
|
||||
}
|
||||
else if (ex instanceof ServletRequestBindingException) {
|
||||
return handleServletRequestBindingException(
|
||||
(ServletRequestBindingException) ex, request, response, handler);
|
||||
|
@ -212,10 +217,6 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
|
|||
return handleMethodArgumentNotValidException(
|
||||
(MethodArgumentNotValidException) ex, request, response, handler);
|
||||
}
|
||||
else if (ex instanceof MissingServletRequestPartException) {
|
||||
return handleMissingServletRequestPartException(
|
||||
(MissingServletRequestPartException) ex, request, response, handler);
|
||||
}
|
||||
else if (ex instanceof BindException) {
|
||||
return handleBindException((BindException) ex, request, response, handler);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue