public static PropertyDescriptor[] getPropertyDescriptors(Class clazz) throws AppException {
BeanInfo beanInfo = null;
try {
beanInfo = Introspector.getBeanInfo(clazz);
} catch (IntrospectionException e) {
throw new AppException("Can not get bean info!");
}
return beanInfo.getPropertyDescriptors();
}
本文介绍了一段Java代码,该代码通过反射机制获取指定类的所有属性描述符。利用JavaBeans规范中的Introspector类,可以方便地获取到Class对象对应的BeanInfo对象,并从中抽取PropertyDescriptors数组。
1663

被折叠的 条评论
为什么被折叠?



