diff --git a/spring-web/src/main/java/org/springframework/web/bind/MethodArgumentNotValidException.java b/spring-web/src/main/java/org/springframework/web/bind/MethodArgumentNotValidException.java index ce1c20e7dd..8dda0674b3 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/MethodArgumentNotValidException.java +++ b/spring-web/src/main/java/org/springframework/web/bind/MethodArgumentNotValidException.java @@ -75,7 +75,9 @@ public class MethodArgumentNotValidException extends BindException implements Er * @param executable the executable that failed validation * @param bindingResult the results of the validation * @since 6.0.5 + * @deprecated in favor of {@link #MethodArgumentNotValidException(MethodParameter, BindingResult)} */ + @Deprecated(since = "6.0.10", forRemoval = true) public MethodArgumentNotValidException(Executable executable, BindingResult bindingResult) { super(bindingResult); this.parameter = null; diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java index df8b4fb82c..2a0f45f566 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessor.java @@ -233,6 +233,7 @@ public class ModelAttributeMethodProcessor implements HandlerMethodArgumentResol * after constructor resolution. * @param ctor the constructor to use * @param attributeName the name of the attribute (never {@code null}) + * @param parameter the method parameter declaration * @param binderFactory for creating WebDataBinder instance * @param webRequest the current request * @return the created model attribute (never {@code null}) @@ -340,7 +341,7 @@ public class ModelAttributeMethodProcessor implements HandlerMethodArgumentResol BindingResult result = binder.getBindingResult(); ObjectError error = new ObjectError(ctor.getName(), cause.getMessage()); result.addError(error); - throw new MethodArgumentNotValidException(ctor, result); + throw new MethodArgumentNotValidException(parameter, result); } else { throw ex;