问题描述
获得了一个方法,该方法返回带有查询结果的ArrayList:
public ArrayList<String> answerRequest(String table,String attribut) {
ArrayList<String> res = new ArrayList<String>();
try (Statement st = getMysqLConnection().createStatement();) {
ResultSet daten = st.executeQuery("SELECT " + table + "." + attribut + " from " + table);
while (daten.next()) {
res.add(daten.getString(1));
}
} catch (Exception e) {
// Todo Auto-generated catch block
e.printstacktrace();
}
return res;
}
<%
ArrayList<String> res = new MysqLConnUtils().answerRequest("betreiber","name");
for (int i = 0; i < res.size(); i++) {
out.println(res.get(i));
}
%>
我得到了这个错误,但我没有落后,因为函数“ MysqLConnUtils()。answerRequest”显然返回一个数组...
An error occurred at line: [17] in the jsp file: [/TESTJSP.jsp]
Type mismatch: cannot convert from void to ArrayList<String>
14: <body>
15:
16: <%
17: ArrayList<String> res = new MysqLConnUtils().answerRequest("betreiber","name");
18: for (int i = 0; i < res.size(); i++) {
19: out.println(res.get(i));
20: }
感谢您的帮助!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)