/** * list<DTO> 转 list<Map<String,Object>> * * @param list * @param <T> * @return */ public static <T> List<Map<String, Object>> listConvert(List<T> list) { List<Map<String, Object>> list_map = new ArrayList<Map<String, Object>>(); // 定义List<Map<String, Object>>数组<br> // list为外部传进来的list集合 if (CollectionUtils.isNotEmpty(list)) { list.forEach(item ->{// PropertyUtils.describe(Object)转换 Map<String, Object> map = null; try { map = (Map<String, Object>) PropertyUtils.describe(item); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } list_map.add(map ); }); } return list_map; }
标签:map,List,describe,list,printStackTrace,catch From: https://www.cnblogs.com/zhaoyijunjava/p/16722587.html