public boolean isObjectFieldEmpty(Object object) { boolean flag = false; if (object != null) { Class<?> entity = object.getClass(); Field[] fields = entity.getDeclaredFields();//獲取該類的全部成員變量(私有的) for (Field field : fields) { try { field.setAccessible(true);//成員變量爲private,必須爲true 不然拋出異常 if (field.get(object) != null && !"".equals(field.get(object))) { flag = true; break; } } catch (IllegalAccessException e) { e.printStackTrace(); } } } return flag;}