利用反射获取对象值

import org.apache.commons.beanutils.BeanUtils;

private String getValueByField(Object object, String field) { String retValue = null; if (CommonUtils.isEmpty(object)) { return null; } try { retValue = BeanUtils.getProperty(object, field); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { logger.error("VerticalPriceCycleFrontDataService getValueByField", e); } return retValue; }

 

posted @ 2022-04-02 15:04  屠城校尉杜  阅读(86)  评论(0)    收藏  举报