@@ -53,11 +53,13 @@ public InitBinderDataBinderFactory(@Nullable List<InvocableHandlerMethod> binder
53
53
this .binderMethods = (binderMethods != null ? binderMethods : Collections .emptyList ());
54
54
}
55
55
56
+
56
57
/**
57
58
* Initialize a WebDataBinder with {@code @InitBinder} methods.
58
59
* <p>If the {@code @InitBinder} annotation specifies attributes names,
59
60
* it is invoked only if the names include the target object name.
60
- * @throws Exception if one of the invoked @{@link InitBinder} methods fail.
61
+ * @throws Exception if one of the invoked @{@link InitBinder} methods fails
62
+ * @see #isBinderMethodApplicable
61
63
*/
62
64
@ Override
63
65
public void initBinder (WebDataBinder dataBinder , NativeWebRequest request ) throws Exception {
@@ -66,19 +68,19 @@ public void initBinder(WebDataBinder dataBinder, NativeWebRequest request) throw
66
68
Object returnValue = binderMethod .invokeForRequest (request , null , dataBinder );
67
69
if (returnValue != null ) {
68
70
throw new IllegalStateException (
69
- "@InitBinder methods should return void: " + binderMethod );
71
+ "@InitBinder methods must not return a value (should be void) : " + binderMethod );
70
72
}
71
73
}
72
74
}
73
75
}
74
76
75
77
/**
76
- * Whether the given {@code @InitBinder} method should be used to initialize
77
- * the given WebDataBinder instance. By default we check the attributes
78
- * names of the annotation, if present .
78
+ * Determine whether the given {@code @InitBinder} method should be used
79
+ * to initialize the given {@link WebDataBinder} instance. By default we
80
+ * check the specified attribute names in the annotation value , if any .
79
81
*/
80
- protected boolean isBinderMethodApplicable (HandlerMethod binderMethod , WebDataBinder dataBinder ) {
81
- InitBinder ann = binderMethod .getMethodAnnotation (InitBinder .class );
82
+ protected boolean isBinderMethodApplicable (HandlerMethod initBinderMethod , WebDataBinder dataBinder ) {
83
+ InitBinder ann = initBinderMethod .getMethodAnnotation (InitBinder .class );
82
84
Assert .state (ann != null , "No InitBinder annotation" );
83
85
String [] names = ann .value ();
84
86
return (ObjectUtils .isEmpty (names ) || ObjectUtils .containsElement (names , dataBinder .getObjectName ()));
0 commit comments