如何对JSP查询列表的一个数字字段进行页面合计,
"培训内容 维费金额合计 时间 "
100
200
200
合计:500 其中 select a,sum(维费金额) as 维费金额合计 from table
这个"合计:500"在页面上怎么写for循环,请给出实例.谢谢.解决马上给分.
"培训内容 维费金额合计 时间 "
100
200
200
合计:500 其中 select a,sum(维费金额) as 维费金额合计 from table
这个"合计:500"在页面上怎么写for循环,请给出实例.谢谢.解决马上给分.
把代码贴出来看看呢
if (rows != null && !rows.isEmpty()) {
%>
<%
Row row = null;
for (int i = 0; i < rows.getSize(); i++) {
row = rows.getRow(i);
%> <tr class="data1" title="dd" >
<td width="18%" bgcolor="#F3F9EF" onClick="openINFO('<%=row.getStrValue("TAB_ID") %>');">
<div align="center"><%=row.getValue("SUM_PACT_AMOUNT")%> </div></td>
<td bgcolor="#F3F9EF" onClick="openINFO('<%=row.getStrValue("TAB_ID") %>');">
<div align="center"><%=row.getValue("SUM_CURRENT_AMOUNT")%> </div></td>
</tr>
float total = 0;
在for循环里
total += Float.valueOf(row.getValue("???"));
最后在需要放total的地方<%=total%>
float total = 0;
if (rows != null && !rows.isEmpty()) {
%>
<%
Row row = null;
for (int i = 0; i < rows.getSize(); i++) {
row = rows.getRow(i);
total += Float.valueOf(row.getValue("SUM_CURRENT_AMOUNT"));//获取你的金额,请修改相应字段名
%>
<tr class="data1" title="dd" >
<td width="18%" bgcolor="#F3F9EF" onClick="openINFO(' <%=row.getStrValue("TAB_ID") %>');">
<div align="center"> <%=row.getValue("SUM_PACT_AMOUNT")%> </div> </td> <td bgcolor="#F3F9EF" onClick="openINFO(' <%=row.getStrValue("TAB_ID") %>');">
<div align="center"> <%=row.getValue("SUM_CURRENT_AMOUNT")%> </div> </td>
</tr>
<%}
}
%>
<tr>
<td>合计:</td><td><%=total%></td>
</tr>
float total = 0;
RowSet rows = (RowSet) request.getAttribute("fz1");
if (rows != null && !rows.isEmpty()) {
%>
<%
Row row = null;
for (int i = 0; i < rows.getSize(); i++) {
row = rows.getRow(i);
Float total1 += Float.valueOf(row.getValue("SUM_PACT_AMOUNT"));
Float total2 += Float.valueOf(row.getValue("SUM_CURRENT_AMOUNT"));
%>
“total1 += ”和"total2 += "语法报错
total += Float.valueOf(row.getValue("SUM_CURRENT_AMOUNT"));又"valueOf"这里报错