List<Integer> list = dao.listKey();
通过listKey()从数据库中获取返回值,且将resultType 变成String,
此时,list中,存放的变成了字符串,程序执行错误,顺带去研究了下,什么情况下,可以将String放入此集合中。
参考了下https://blog.csdn.net/sinat_28789467/article/details/57415998,这个里面写的还是比较清楚的,附段代码:
Class<?> clz = list.getClass();
Method method;
try {
method = clz.getMethod("add", Object.class);
method.invoke(list, "123");
method.invoke(list, "456");
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
通过这段代码,可以在此list中放入任何值