WxjMLove 2017-05-18 01:25 采纳率: 0%
浏览 1154

java通过反射调用方法抛出异常

String ivkClass="com.jbh.router.core.handler.ucfPayImpl.DemoHandlerImpl";
Map map=responseModel.getResponseMap();
//组织参数
Map[] argsClass = new Map[1];
argsClass[0] = map;
responseModel = (ResponseModel) invokeMethod(ivkClass, "demo1", argsClass); //调用

public Object invokeMethod(Object owner, String methodName, Object[] args)
throws Exception {
Class ownerClass = owner.getClass();
Class[] argsClass = new Class[args.length];
for (int i = 0, j = args.length; i < j; i++) {
argsClass[i] = args[i].getClass();
}
Method method = ownerClass.getMethod(methodName, argsClass);
return method.invoke(owner, args);
}

  • 写回答

1条回答 默认 最新

  • WxjMLove 2017-05-18 01:30
    关注

    public ResponseModel demo1(Map map){
    HttpReqeustModel httpReqeustModel = requestModelBuilder.demo1(map);
    ResponseModel responseModel = new ResponseModel();
    System.out.println("------demo1测试类---------");
    return responseModel;
    }

    这个是调用的哪个方法
    
    评论

报告相同问题?

悬赏问题

  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页