获取JavaBean 中的字段

来源:互联网 发布:ibm金融行业人工智能 编辑:程序博客网 时间:2024/05/22 00:42

import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;

        List fieldList=new ArrayList();
        try {
            BeanInfo beanInfo = Introspector.getBeanInfo(someClass);
            PropertyDescriptor pd[]=beanInfo.getPropertyDescriptors();
            for(int i=0;i<pd.length;i++){
            fieldList.add(pd[i].getName());
            }
        } catch (IntrospectionException e) {
            e.printStackTrace();
        }
 

原创粉丝点击