Map<String, String> properties = new HashMap<>(); properties.put("name", "John"); properties.put("age", "25"); Person person = new Person(); BeanUtilsBean.getInstance().populate(person, properties); String city = BeanUtils.getProperty(person, "address.city"); Converter myConverter = new MyConverter(); ConvertUtils.register(myConverter, String.class); String value = ConvertUtils.convert(person.getName()); import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.beanutils.PropertyUtilsBean; PropertyUtils.getProperty(person, "name"); Object value = PropertyUtils.getProperty(person, "name"); if (value != null) { } <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.9.4</version> </dependency> groovy implementation 'commons-beanutils:commons-beanutils:1.9.4'


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