only try to convert to String if canConvert returns true

This commit is contained in:
Juergen Hoeller 2009-12-15 09:59:11 +00:00
parent 2764024351
commit 1b0c6b848d
1 changed files with 4 additions and 3 deletions

View File

@ -116,9 +116,10 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
} }
if (this.conversionService != null) { if (this.conversionService != null) {
// Try custom formatter... // Try custom formatter...
TypeDescriptor td = getPropertyAccessor().getPropertyTypeDescriptor(fixedField); TypeDescriptor fieldDesc = getPropertyAccessor().getPropertyTypeDescriptor(fixedField);
if (td != null) { TypeDescriptor stringDesc = TypeDescriptor.valueOf(String.class);
return this.conversionService.convert(value, td, TypeDescriptor.valueOf(String.class)); if (fieldDesc != null && this.conversionService.canConvert(fieldDesc, stringDesc)) {
return this.conversionService.convert(value, fieldDesc, stringDesc);
} }
} }
return value; return value;