|
|
|
@ -28,7 +28,6 @@ import org.springframework.beans.BeanWrapperImpl; |
|
|
|
import org.springframework.beans.InvalidPropertyException; |
|
|
|
import org.springframework.beans.InvalidPropertyException; |
|
|
|
import org.springframework.beans.MutablePropertyValues; |
|
|
|
import org.springframework.beans.MutablePropertyValues; |
|
|
|
import org.springframework.beans.PropertyValue; |
|
|
|
import org.springframework.beans.PropertyValue; |
|
|
|
import org.springframework.core.convert.ConversionService; |
|
|
|
|
|
|
|
import org.springframework.core.convert.TypeDescriptor; |
|
|
|
import org.springframework.core.convert.TypeDescriptor; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.validation.DataBinder; |
|
|
|
import org.springframework.validation.DataBinder; |
|
|
|
@ -48,8 +47,6 @@ public class RelaxedDataBinder extends DataBinder { |
|
|
|
|
|
|
|
|
|
|
|
private boolean ignoreNestedProperties; |
|
|
|
private boolean ignoreNestedProperties; |
|
|
|
|
|
|
|
|
|
|
|
private ConversionService relaxedConversionService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new {@link RelaxedDataBinder} instance. |
|
|
|
* Create a new {@link RelaxedDataBinder} instance. |
|
|
|
* @param target the target into which properties are bound |
|
|
|
* @param target the target into which properties are bound |
|
|
|
@ -79,19 +76,12 @@ public class RelaxedDataBinder extends DataBinder { |
|
|
|
this.ignoreNestedProperties = ignoreNestedProperties; |
|
|
|
this.ignoreNestedProperties = ignoreNestedProperties; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void setConversionService(ConversionService conversionService) { |
|
|
|
|
|
|
|
super.setConversionService(conversionService); |
|
|
|
|
|
|
|
this.relaxedConversionService = new RelaxedConversionService(getConversionService()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void initBeanPropertyAccess() { |
|
|
|
public void initBeanPropertyAccess() { |
|
|
|
super.initBeanPropertyAccess(); |
|
|
|
super.initBeanPropertyAccess(); |
|
|
|
this.relaxedConversionService = (this.relaxedConversionService != null |
|
|
|
|
|
|
|
? this.relaxedConversionService : new RelaxedConversionService(getConversionService())); |
|
|
|
|
|
|
|
// Hook in the RelaxedConversionService
|
|
|
|
// Hook in the RelaxedConversionService
|
|
|
|
getInternalBindingResult().initConversion(relaxedConversionService); |
|
|
|
getInternalBindingResult().initConversion( |
|
|
|
|
|
|
|
new RelaxedConversionService(getConversionService())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -120,13 +110,13 @@ public class RelaxedDataBinder extends DataBinder { |
|
|
|
propertyValues = addMapPrefix(propertyValues); |
|
|
|
propertyValues = addMapPrefix(propertyValues); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BeanWrapper targetWrapper = new BeanWrapperImpl(target); |
|
|
|
BeanWrapper wrapper = new BeanWrapperImpl(target); |
|
|
|
targetWrapper.setConversionService(this.relaxedConversionService); |
|
|
|
wrapper.setConversionService(new RelaxedConversionService(getConversionService())); |
|
|
|
targetWrapper.setAutoGrowNestedPaths(true); |
|
|
|
wrapper.setAutoGrowNestedPaths(true); |
|
|
|
|
|
|
|
|
|
|
|
List<PropertyValue> list = propertyValues.getPropertyValueList(); |
|
|
|
List<PropertyValue> list = propertyValues.getPropertyValueList(); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
modifyProperty(propertyValues, targetWrapper, list.get(i), i); |
|
|
|
modifyProperty(propertyValues, wrapper, list.get(i), i); |
|
|
|
} |
|
|
|
} |
|
|
|
return propertyValues; |
|
|
|
return propertyValues; |
|
|
|
} |
|
|
|
} |
|
|
|
|