/** * 设置对象属性值 * 默认值 * * @param obj * @param fieldName * @param value */ public static void setObjFieldVal(Object obj, String fieldName, Object value) { try { Field field = obj.getClass().getDeclaredField(fieldName); field.setAccessible(true); field.set(obj, value); } catch (NoSuchFieldException e) { log.error("error while set obj field value", e); } catch (IllegalAccessException e1) { log.error("error while set obj field value", e1); } }