映射

Class clazz = Class.forName("com.npsel.report.action.CommonMethod");

// 无参数

Method method = clazz.getDeclaredMethod("get"+tdRecord.toUpperCase());
tdRecord = (String) method.invoke(clazz.newInstance());

// 有参数

Method method = clazz.getDeclaredMethod("say" + methodStr, new Class[]{String.class,int.class});
method.invoke(clazz.newInstance(), new Object[]{name,age});

 
// 构造函数

Constructor constructor = clazz.getConstructor(Except.class);
EdiServiceDao ediServiceDao = (EdiServiceDao) constructor.newInstance(except);
ediServiceDao.getSBufferOutput(request, response);

posted @ 2017-06-02 20:47  ☀Beans✡✌  阅读(101)  评论(0编辑  收藏  举报