Field[] fields=invest.getClass().getDeclaredFields();
for(int i=0;i<fields.length;i++){
PropertyDescriptor pd = new PropertyDescriptor(fields[i].getName(),invest.getClass());
Method getMethod = pd.getReadMethod();//获得get方法
Object o = getMethod.invoke(invest);//执行get方法返回一个Object
map.put(fields[0].getName(),o);
}
对JAVA Bean使用PropertyDescriptor反射调用JAVA方法
最新推荐文章于 2023-04-15 22:14:21 发布