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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.web.multipart.support;
|
package org.springframework.web.multipart.support;
|
||||||
|
|
||||||
import jakarta.servlet.ServletException;
|
import org.springframework.web.bind.ServletRequestBindingException;
|
||||||
|
|
||||||
import org.springframework.web.multipart.MultipartResolver;
|
import org.springframework.web.multipart.MultipartResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,10 +29,11 @@ import org.springframework.web.multipart.MultipartResolver;
|
||||||
* e.g. no {@link MultipartResolver}.
|
* e.g. no {@link MultipartResolver}.
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
|
* @author Wonchul Heo
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class MissingServletRequestPartException extends ServletException {
|
public class MissingServletRequestPartException extends ServletRequestBindingException {
|
||||||
|
|
||||||
private final String requestPartName;
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
* detected, {@link ExceptionHandlerExceptionResolver} must be configured.
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
|
* @author Wonchul Heo
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
* @see #handleException(Exception, WebRequest)
|
* @see #handleException(Exception, WebRequest)
|
||||||
* @see org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver
|
* @see org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver
|
||||||
|
@ -108,13 +109,13 @@ public abstract class ResponseEntityExceptionHandler {
|
||||||
HttpMediaTypeNotAcceptableException.class,
|
HttpMediaTypeNotAcceptableException.class,
|
||||||
MissingPathVariableException.class,
|
MissingPathVariableException.class,
|
||||||
MissingServletRequestParameterException.class,
|
MissingServletRequestParameterException.class,
|
||||||
|
MissingServletRequestPartException.class,
|
||||||
ServletRequestBindingException.class,
|
ServletRequestBindingException.class,
|
||||||
ConversionNotSupportedException.class,
|
ConversionNotSupportedException.class,
|
||||||
TypeMismatchException.class,
|
TypeMismatchException.class,
|
||||||
HttpMessageNotReadableException.class,
|
HttpMessageNotReadableException.class,
|
||||||
HttpMessageNotWritableException.class,
|
HttpMessageNotWritableException.class,
|
||||||
MethodArgumentNotValidException.class,
|
MethodArgumentNotValidException.class,
|
||||||
MissingServletRequestPartException.class,
|
|
||||||
BindException.class,
|
BindException.class,
|
||||||
NoHandlerFoundException.class,
|
NoHandlerFoundException.class,
|
||||||
AsyncRequestTimeoutException.class
|
AsyncRequestTimeoutException.class
|
||||||
|
@ -143,6 +144,10 @@ public abstract class ResponseEntityExceptionHandler {
|
||||||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||||
return handleMissingServletRequestParameter((MissingServletRequestParameterException) ex, headers, status, 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) {
|
else if (ex instanceof ServletRequestBindingException) {
|
||||||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||||
return handleServletRequestBindingException((ServletRequestBindingException) ex, headers, status, request);
|
return handleServletRequestBindingException((ServletRequestBindingException) ex, headers, status, request);
|
||||||
|
@ -167,10 +172,6 @@ public abstract class ResponseEntityExceptionHandler {
|
||||||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||||
return handleMethodArgumentNotValid((MethodArgumentNotValidException) ex, headers, status, 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) {
|
else if (ex instanceof BindException) {
|
||||||
HttpStatus status = HttpStatus.BAD_REQUEST;
|
HttpStatus status = HttpStatus.BAD_REQUEST;
|
||||||
return handleBindException((BindException) ex, headers, status, 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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>
|
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr class="rowColor">
|
* <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>ServletRequestBindingException</p></td>
|
||||||
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
@ -113,10 +117,6 @@ import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
|
||||||
* <td><p>MethodArgumentNotValidException</p></td>
|
* <td><p>MethodArgumentNotValidException</p></td>
|
||||||
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr class="rowColor">
|
|
||||||
* <td><p>MissingServletRequestPartException</p></td>
|
|
||||||
* <td><p>400 (SC_BAD_REQUEST)</p></td>
|
|
||||||
* </tr>
|
|
||||||
* <tr class="altColor">
|
* <tr class="altColor">
|
||||||
* <td><p>BindException</p></td>
|
* <td><p>BindException</p></td>
|
||||||
* <td><p>400 (SC_BAD_REQUEST)</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 Arjen Poutsma
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
* @author Wonchul Heo
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
* @see org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
|
* @see org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
|
||||||
*/
|
*/
|
||||||
|
@ -188,6 +189,10 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
|
||||||
return handleMissingServletRequestParameter(
|
return handleMissingServletRequestParameter(
|
||||||
(MissingServletRequestParameterException) ex, request, response, handler);
|
(MissingServletRequestParameterException) ex, request, response, handler);
|
||||||
}
|
}
|
||||||
|
else if (ex instanceof MissingServletRequestPartException) {
|
||||||
|
return handleMissingServletRequestPartException(
|
||||||
|
(MissingServletRequestPartException) ex, request, response, handler);
|
||||||
|
}
|
||||||
else if (ex instanceof ServletRequestBindingException) {
|
else if (ex instanceof ServletRequestBindingException) {
|
||||||
return handleServletRequestBindingException(
|
return handleServletRequestBindingException(
|
||||||
(ServletRequestBindingException) ex, request, response, handler);
|
(ServletRequestBindingException) ex, request, response, handler);
|
||||||
|
@ -212,10 +217,6 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
|
||||||
return handleMethodArgumentNotValidException(
|
return handleMethodArgumentNotValidException(
|
||||||
(MethodArgumentNotValidException) ex, request, response, handler);
|
(MethodArgumentNotValidException) ex, request, response, handler);
|
||||||
}
|
}
|
||||||
else if (ex instanceof MissingServletRequestPartException) {
|
|
||||||
return handleMissingServletRequestPartException(
|
|
||||||
(MissingServletRequestPartException) ex, request, response, handler);
|
|
||||||
}
|
|
||||||
else if (ex instanceof BindException) {
|
else if (ex instanceof BindException) {
|
||||||
return handleBindException((BindException) ex, request, response, handler);
|
return handleBindException((BindException) ex, request, response, handler);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue