将对象转换成Map<String, String>格式
/** * 将对象转换成Map<String, String>格式 * * @param obj * @return */ public static HashMap<String, String> getNamValMap(Object obj, boolean isSort) { HashMap<String, String> map = new HashMap<>(); Field[] fieldArr = obj.getClass().getDeclaredFields(); try { for (Field field : fieldArr) { field.setAccessible(true); if (field.get(obj) != null && !"".equals(field.get(obj).toString())) { map.put(field.getName(), field.get(obj).toString()); } } } catch (IllegalAccessException e) { log.error(e.getMessage()); } return map; }