恢复Java Bean属性
/*nowjava 提 供*/ //package com.nowjava; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; import java.util.Map; public class Main { public static void restoreProp(Object bean, Map<String, Object> propMap) { try { BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass()); PropertyDescriptor[] descriptors = beanInfo .getPropertyDescriptors(); for (PropertyDescriptor des : descriptors) {/** 时 代 Java - nowjava.com 提 供 **/ String fieldName = des.getName(); if (propMap.containsKey(fieldName)) { Method setter = des.getWriteMethod(); setter.invoke(bean,