有没有办法Result<Record>
从 jOOQ 中循环<c:forEach>
?
这是getter方法:
public Vector<Map<String, String>> getUsers() {
Factory sql = new Factory(Database.getInstance().connect(), SQLDialect.MYSQL);
Result<Record> results = sql.select().from("users").fetch();
Vector<Map<String, String>> v = new Vector<Map<String, String>>();
for(Record item: results) {
Map<String, String> m = new HashMap<String, String>();
m.put("login", item.getValueAsString("login"));
// other columns
v.add(m);
}
return v;
}
这是视图:
<c:forEach var="u" items="${users}">
${u.login} <br />
</c:forEach>
有没有办法让我的getter方法更简单,比如:
public Result<Record> getUsers() {
Factory sql = new Factory(Database.getInstance().connect(), SQLDialect.MYSQL);
reutrn sql.select().from("users").fetch();
}
但正如前面提到的,我不知道如何循环遍历它<c:forEach>
,或者它是不可能的?