如何将我的数组列表检索到 html 表中?
我的数组列表:
[
1, 2011-05-10, 1, 22.0,
2, 2011-05-10, 2, 5555.0,
3, 2011-05-11, 3, 123.0,
4, 2011-05-11, 2, 212.0,
5, 2011-05-30, 1, 3000.0,
6, 2011-05-30, 1, 30.0,
7, 2011-06-06, 1, 307.0,
8, 2011-06-06, 1, 307.0 ]
out.println("<html>");
out.println("<head>");
out.println("<title>Counter</title>");
out.println("</head>");
out.println("<body>");
out.println("<table border=\"1\">");
out.println("<tr>");
for (int i = 0; i < ex.getExpenses().size(); i++) {
out.println("<td>" + ex.getExpenses().get(i) + "</td>");
if (i>0 && i%4==0) {
out.println("</tr><tr>");
}
}
out.println("</tr>");
out.println("</table>");
out.println("</body>");
out.println("</html>");
这实际上不起作用,因为 arraylist 以 0 开头,它给了我如下所示的表:
我如何获得如下所示的表格:
1 2011-05-10 1 22.0
2 2011-05-10 2 5555.0
3 2011-05-11 3 123.0
4 2011-05-11 2 212.0
5 2011-05-30 1 3000.0
6 2011-05-30 1 30.0
7 2011-06-06 1 307.0
8 2011-06-06 1 307.0