Map<String, Object> fieldMap =new HashMap<String, Object>(); BeanInfo beanInfo = Introspector.getBeanInfo(【javabean类名】.class, Object.class);
//获取所有的属性描述器
PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
for(PropertyDescriptor pd:pds){
String key = pd.getName();
Method getter = pd.getReadMethod();
Object value = getter.invoke(【实例化的javaBean】);
fieldMap.put(key, value);
}
相关文章
- 09-12base64转MultipartFile方法
- 09-12Python实现半角转全角的方法
- 09-12在实现接口时,方法重写可以实现多态,泛型不可以实现多态,必须要强转才能使用
- 09-12微信 xml 转 Map
- 09-12《转》在win7,boa-constructor 0.6.1 的palette面板中没有控件图标的解决方法
- 09-12python获取文件扩展名的方法(转)
- 09-12[转]简单的动态修改RDLC报表页边距和列宽的方法
- 09-12Dapper官方教程翻译5:Dapper方法之QueryFirstOrDefault(转)
- 09-12Dapper官方教程翻译6:Dapper方法之QuerySingle(转)
- 09-12Dapper官方教程翻译7:Dapper方法之QuerySingleOrDefault(转)