通过getMethod方法,可以动态调用类的方法Object[] args = new Integer[]{keyValue};
Class[] argsClass = new Class[args.length];
for (int i = 0, j = args.length; i
argsClass[i] = args[i].getClass();
}
try {
Method m = entity.getClass().getMethod("set" + methodName, argsClass);
m.invoke(entity, args);
} catch(NoSuchMethodException e) {
logger.error(e.toString());
} catch (IllegalAccessException e) {
logger.error(e.toString());
} catch (InvocationTargetException e) {
logger.error(e.toString());
}