Example usage for org.springframework.validation DataBinder setIgnoreInvalidFields

List of usage examples for org.springframework.validation DataBinder setIgnoreInvalidFields

Introduction

In this page you can find the example usage for org.springframework.validation DataBinder setIgnoreInvalidFields.

Prototype

public void setIgnoreInvalidFields(boolean ignoreInvalidFields) 

Source Link

Document

Set whether to ignore invalid fields, that is, whether to ignore bind parameters that have corresponding fields in the target object which are not accessible (for example because of null values in the nested path).

Usage

From source file:com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor.java

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

    if (beanName.equals(this.beanName)) {
        DataBinder dataBinder = new DataBinder(bean);
        // TODO ignore invalid fields by annotation attribute
        dataBinder.setIgnoreInvalidFields(true);
        dataBinder.bind(propertyValues);
        if (log.isInfoEnabled()) {
            log.info("The properties of bean [name : " + beanName + "] have been binding by values : "
                    + Arrays.asList(propertyValues.getPropertyValues()));
        }/* w ww.  j  a  v a2s .c om*/
    }

    return bean;

}