/**
* @author: tianyong
* @time: 2019/6/18 18:51
* @description:反射调用方法,获取return值
*/
public static String reflectInvokeMethod(Class<?> clazz,String mn,Map params){
String res = "";
try {
Method method = clazz.getMethod(mn,Map.class);
method.setAccessible(true);
res = method.invoke(clazz.newInstance(),params).toString();
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
调用: String res= reflectInvokeMethod(ChartHandle.class, method,params);
返回的res,即为调用方法的返回值
如果本文帮到您了,欢迎关注公众号