Class MethodArgumentNotValidException
java.lang.Object
java.lang.Throwable
java.lang.Exception
org.springframework.validation.BindException
org.springframework.web.bind.MethodArgumentNotValidException
- All Implemented Interfaces:
- Serializable, BindingResult, Errors, ErrorResponse
BindException to be thrown when validation on an argument annotated
with @Valid fails.- Since:
- 3.1
- Author:
- Rossen Stoyanchev, Juergen Hoeller, Sebastien Deleuze
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from interface ErrorResponseErrorResponse.Builder, ErrorResponse.Interceptor
- 
Field SummaryFields inherited from interface BindingResultMODEL_KEY_PREFIXFields inherited from interface ErrorsNESTED_PATH_SEPARATOR
- 
Constructor SummaryConstructorsConstructorDescriptionMethodArgumentNotValidException(MethodParameter parameter, BindingResult bindingResult) Constructor forMethodArgumentNotValidException.
- 
Method SummaryModifier and TypeMethodDescriptiongetBody()Return the body for the response, formatted as an RFC 9457ProblemDetailwhosestatusshould match the response status.Object[]Return arguments to use along with amessage codeto resolve the problem "detail" for this exception through aMessageSource.Object[]getDetailMessageArguments(MessageSource source, Locale locale) Variant ofErrorResponse.getDetailMessageArguments()that uses the givenMessageSourcefor resolving the message argument values.Returns diagnostic information about the errors held in this object.final MethodParameterReturn the method parameter that failed validation.Return the HTTP status code to use for the response.Methods inherited from class BindExceptionaddAllErrors, addError, equals, findEditor, getAllErrors, getBindingResult, getErrorCount, getFieldError, getFieldError, getFieldErrorCount, getFieldErrorCount, getFieldErrors, getFieldErrors, getFieldType, getFieldValue, getGlobalError, getGlobalErrorCount, getGlobalErrors, getModel, getNestedPath, getObjectName, getPropertyEditorRegistry, getRawFieldValue, getSuppressedFields, getTarget, hasErrors, hasFieldErrors, hasFieldErrors, hasGlobalErrors, hashCode, popNestedPath, pushNestedPath, recordFieldValue, recordSuppressedField, reject, reject, reject, rejectValue, rejectValue, rejectValue, resolveMessageCodes, resolveMessageCodes, setNestedPathMethods inherited from class ThrowableaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringMethods inherited from interface ErrorResponsegetDetailMessageCode, getHeaders, getTitleMessageCode, getTypeMessageCode, updateAndGetBodyMethods inherited from interface ErrorsfailOnError, toString
- 
Constructor Details- 
MethodArgumentNotValidExceptionConstructor forMethodArgumentNotValidException.- Parameters:
- parameter- the parameter that failed validation
- bindingResult- the results of the validation
 
 
- 
- 
Method Details- 
getParameterReturn the method parameter that failed validation.
- 
getStatusCodeDescription copied from interface:ErrorResponseReturn the HTTP status code to use for the response.- Specified by:
- getStatusCodein interface- ErrorResponse
 
- 
getBodyDescription copied from interface:ErrorResponseReturn the body for the response, formatted as an RFC 9457ProblemDetailwhosestatusshould match the response status.Note: The returned ProblemDetailmay be updated before the response is rendered, for example, viaErrorResponse.updateAndGetBody(MessageSource, Locale). Therefore, implementing methods should use an instance field, and should not re-create theProblemDetailon every call, nor use a static variable.- Specified by:
- getBodyin interface- ErrorResponse
 
- 
getDetailMessageArgumentsDescription copied from interface:ErrorResponseVariant ofErrorResponse.getDetailMessageArguments()that uses the givenMessageSourcefor resolving the message argument values.This is useful for example to expand message codes from validation errors. The default implementation delegates to ErrorResponse.getDetailMessageArguments(), ignoring the suppliedMessageSourceandLocale.- Specified by:
- getDetailMessageArgumentsin interface- ErrorResponse
- Parameters:
- source- the- MessageSourceto use for the lookup
- locale- the- Localeto use for the lookup
 
- 
getDetailMessageArgumentsDescription copied from interface:ErrorResponseReturn arguments to use along with amessage codeto resolve the problem "detail" for this exception through aMessageSource. The arguments are expanded into placeholders of the message value, for example, "Invalid content type {0}".- Specified by:
- getDetailMessageArgumentsin interface- ErrorResponse
 
- 
getMessageDescription copied from class:BindExceptionReturns diagnostic information about the errors held in this object.- Overrides:
- getMessagein class- BindException
 
 
-