import java.lang.reflect.Field;
方法如下:
/**
* 验证对象中属性是否为null
*
* @param vo
* @return
* @throws ServiceException
*/
protected boolean checkParamOfObj(AbstractVO vo) throws ServiceException,
IllegalArgumentException, IllegalAccessException {
log.info("服务层操作:验证对象中属性是否为null 方法checkParamOfObj(AbstractVO ["+ vo +"])");
Field[] field1 = vo.getClass().getDeclaredFields();
Boolean bool = false;
for (int i = 0; i < field1.length; i++) {
field1[i].setAccessible(true);
if (field1[i].get(vo) != null) {
bool = true;
}
}
return bool;
}