File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
spring-context/src/main/java/org/springframework/validation Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -125,15 +125,22 @@ public List<FieldError> getFieldErrors() {
125
125
@ Override
126
126
@ Nullable
127
127
public Object getFieldValue (String field ) {
128
+ FieldError fieldError = getFieldError (field );
129
+ if (fieldError != null ) {
130
+ return fieldError .getRejectedValue ();
131
+ }
132
+
128
133
PropertyDescriptor pd = BeanUtils .getPropertyDescriptor (this .target .getClass (), field );
129
134
if (pd != null && pd .getReadMethod () != null ) {
130
135
return ReflectionUtils .invokeMethod (pd .getReadMethod (), this .target );
131
136
}
137
+
132
138
Field rawField = ReflectionUtils .findField (this .target .getClass (), field );
133
139
if (rawField != null ) {
134
140
ReflectionUtils .makeAccessible (rawField );
135
141
return ReflectionUtils .getField (rawField , this .target );
136
142
}
143
+
137
144
throw new IllegalArgumentException ("Cannot retrieve value for field '" + field +
138
145
"' - neither a getter method nor a raw field found" );
139
146
}
You can’t perform that action at this time.
0 commit comments