Yes, today I spent a lot of time to check why he cannot return to the page presented, but goes to the page with a white error by default.
After debugging, the source code is received
// org.springframework.web.method.annotation.ModelAttributeMethodProcessor
if BindingResult does not match @Valid , throws isBindExceptionRequired(binder, parameter) returns true, and then directly throws an exception, so it cannot execute code in the controller method.
// org.springframework.web.method.annotation.ModelAttributeMethodProcessor#isBindExceptionRequired protected boolean isBindExceptionRequired(WebDataBinder binder, MethodParameter methodParam) { int i = methodParam.getParameterIndex(); Class<?>[] paramTypes = methodParam.getMethod().getParameterTypes(); boolean hasBindingResult = (paramTypes.length > (i + 1) && Errors.class.isAssignableFrom(paramTypes[i + 1])); return !hasBindingResult; }
source share