public static MapformatHumpName(Map map) { Map newMap = new HashMap (); Iterator > it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = it.next(); String key = entry.getKey(); String newKey = toFormatCol(key); newMap.put(newKey, entry.getValue()); } return newMap; } public static String toFormatCol(String colName) { StringBuilder sb = new StringBuilder(); String[] str = colName.toLowerCase().split("_"); int i = 0; for (String s : str) { if (s.length() == 1) { s = s.toUpperCase(); } i++; if (i == 1) { sb.append(s); continue; } if (s.length() > 0) { sb.append(s.substring(0, 1).toUpperCase()); sb.append(s.substring(1)); } } return sb.toString(); }
然后将Map中的值赋给对应的对象:【注意导的包】



