SourceObject source = new SourceObject(); source.setName("John"); source.setAge(25); TargetObject target = new TargetObject(); BeanUtils.copyProperties(target, source); Person person = new Person(); BeanUtils.setProperty(person, "name", "John"); BeanUtils.setProperty(person, "age", 25); Person person = new Person(); BeanUtils.setProperty(person, "age", "25"); int age = ConvertUtils.convert(BeanUtils.getProperty(person, "age"), Integer.class); <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> </dependency> import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.ConvertUtils;


上一篇:
下一篇:
切换中文