public String resultValue(String objValueTemp, TmpContractInfo tmpContractInfo) throws NoSuchMethodException,
SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Class<TmpContractInfo> clazz = TmpContractInfo.class;
Method method = clazz.getDeclaredMethod(objValueTemp);
Object objValue = method.invoke(tmpContractInfo);
String value = null;
if (objValue != null && objValue instanceof String) {
value = (String) objValue;
}
return value;
}
第一次使用Java反射,拿属性值
最新推荐文章于 2021-12-29 16:32:03 发布