/**
* 将一个对象的非null屬性转为map
*
* @param o
* @return
*/
public Map<String, String> notNullFielsToMap(Object o) {
Class c = o.getClass();
Map<String, String> map = new HashMap<String, String>();
try {
Field[] fs = c.getDeclaredFields();
for (Field f : fs) {
f.setAccessible(true);
Object ob = f.get(o);
if (null!=ob) {
map.put(f.getName(), ob.toString());
}
}
} catch (SecurityException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return map;
}