使用commons-beanutils迭代获取javabean的属性
NoteEntity entity = new NoteEntity(); entity.setNote001("a1"); entity.setNote002("a2"); entity.setNote003("a3"); java.lang.reflect.Field[] fields = entity.getClass().getDeclaredFields(); for (int i = 0; i < fields.length; i++) { String name = fields[i].getName(); if(PropertyUtils.isReadable(entity, name) && PropertyUtils.isWriteable(entity, name)) { System.out.println(name + "___" + BeanUtils.getProperty(entity, name)); } }