普通方法也可以阿,页面中使用如下代码:
...
<%
int i = 0;
String col = "";
while (rs.next()) {
if (i % 4 == 0) { col = rs.getString(1);
%>
<tr><td><%=col%></td>
<%
} else if (i % 3 == 0) { col = rs.getString(1);
%>
<td><%=col%></td></tr>
<%
} else { col = rs.getString(1);
%>
<td><%=col%></td>
<%
}
i ++;
}
%>
...
...
<%
int i = 0;
String col = "";
while (rs.next()) {
if (i % 4 == 0) { col = rs.getString(1);
%>
<tr><td><%=col%></td>
<%
} else if (i % 3 == 0) { col = rs.getString(1);
%>
<td><%=col%></td></tr>
<%
} else { col = rs.getString(1);
%>
<td><%=col%></td>
<%
}
i ++;
}
%>
...
用HashMap各ArrayList结合:每四个放进HashMap中,再将其放入ArrayList中。