本文整理匯總了Java中org.springframework.web.bind.WebDataBinder.setAutoGrowNestedPaths方法的典型用法代碼示例。如果您正苦於以下問題:Java WebDataBinder.setAutoGrowNestedPaths方法的具體用法?Java WebDataBinder.setAutoGrowNestedPaths怎麽用?Java WebDataBinder.setAutoGrowNestedPaths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.web.bind.WebDataBinder
的用法示例。
在下文中一共展示了WebDataBinder.setAutoGrowNestedPaths方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initBinder
import org.springframework.web.bind.WebDataBinder; //導入方法依賴的package包/類
@Override
public void initBinder(WebDataBinder binder, WebRequest request) {
binder.setAutoGrowNestedPaths(this.autoGrowNestedPaths);
if (this.directFieldAccess) {
binder.initDirectFieldAccess();
}
if (this.messageCodesResolver != null) {
binder.setMessageCodesResolver(this.messageCodesResolver);
}
if (this.bindingErrorProcessor != null) {
binder.setBindingErrorProcessor(this.bindingErrorProcessor);
}
if (this.validator != null && binder.getTarget() != null &&
this.validator.supports(binder.getTarget().getClass())) {
binder.setValidator(this.validator);
}
if (this.conversionService != null) {
binder.setConversionService(this.conversionService);
}
if (this.propertyEditorRegistrars != null) {
for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
propertyEditorRegistrar.registerCustomEditors(binder);
}
}
}
示例2: initBinder
import org.springframework.web.bind.WebDataBinder; //導入方法依賴的package包/類
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setAutoGrowNestedPaths(false);
binder.registerCustomEditor(
Long.class,
new CustomNumberEditor(Long.class, true));
binder.registerCustomEditor(
Double.class,
new CustomNumberEditor(Double.class, true));
binder.registerCustomEditor(
BigDecimal.class,
new CustomNumberEditor(
BigDecimal.class,
new DecimalFormat("#,##0.00"),
true));
binder.registerCustomEditor(
Boolean.class,
new CustomBooleanEditor(true));
binder.registerCustomEditor(
Date.class,
new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
binder.registerCustomEditor(
Object.class,
new ObjectTypeEditorHelper());
}
示例3: readJavaType
import org.springframework.web.bind.WebDataBinder; //導入方法依賴的package包/類
/**
* Before call to {@link ObjectMapper#readValue(java.io.InputStream, Class)}
* creates a {@link ServletRequestDataBinder} and put it to current Thread
* in order to be used by the {@link DataBinderDeserializer}.
* <p/>
* Ref: <a href=
* "http://java.dzone.com/articles/java-thread-local-%E2%80%93-how-use">When
* to use Thread Local?</a>
*
* @param javaType
* @param inputMessage
* @return
*/
private Object readJavaType(JavaType javaType, HttpInputMessage inputMessage) {
try {
Object target = null;
String objectName = null;
// CRear el DataBinder con un target object en funcion del javaType,
// ponerlo en el thread local
Class<?> clazz = javaType.getRawClass();
if (Collection.class.isAssignableFrom(clazz)) {
Class<?> contentClazz = javaType.getContentType().getRawClass();
target = new DataBinderList<Object>(contentClazz);
objectName = "list";
}
else if (Map.class.isAssignableFrom(clazz)) {
// TODO Class<?> contentClazz =
// javaType.getContentType().getRawClass();
target = CollectionFactory.createMap(clazz, 0);
objectName = "map";
}
else {
target = BeanUtils.instantiateClass(clazz);
objectName = "bean";
}
WebDataBinder binder = new ServletRequestDataBinder(target,
objectName);
binder.setConversionService(this.conversionService);
binder.setAutoGrowNestedPaths(true);
binder.setValidator(validator);
ThreadLocalUtil.setThreadVariable(
BindingResult.MODEL_KEY_PREFIX.concat("JSON_DataBinder"),
binder);
Object value = getObjectMapper().readValue(inputMessage.getBody(),
javaType);
return value;
}
catch (IOException ex) {
throw new HttpMessageNotReadableException(
"Could not read JSON: ".concat(ex.getMessage()), ex);
}
}