映射到Java Bean
/* 来 自 时 代 J a v a - nowjava.com*/ //package com.nowjava; import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.InvocationTargetException; import java.util.Map; public class Main { public static <T> T toJavaBean(Map<String, ?> map, Class<T> javaBeanClazz) throws IntrospectionException, IllegalAccessException, InstantiationException, InvocationTargetException { BeanInfo beanInfo = Introspector.getBeanInfo(javaBeanClazz); PropertyDescriptor[] propertyDescriptors = beanInfo .getPropertyDescriptors(); T obj = javaBeanClazz.newInstance(); for (int i = 0; i < propertyDescriptors.length; i++) { PropertyDescriptor descriptor = propertyDescriptors[i];//nowjava - 时 代 Java 提供 String propertyName = descriptor.getName();