如何在jsp中显示表中的值? [英] How to display values in table in jsp?

查看:216
本文介绍了如何在jsp中显示表中的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jsp和jstl的新手我正在使用for循环来获取数组中的值来获取输出,但我希望将该输出放入table.how这样可以任何人帮助我?

i am new to jsp and jstl i am working on this code to get the values from array using the for loop.i am getting the output, but i want to put that output into table.how to do this can anyone help me?

for ( int i =0; i < timeSize ; i++)
       {
         out.println(resource[i]);
         out.println(itimespend[i]);
         out.println(icostspend[i]);
         totalcost += itimespend[i] * icostspend[i];          
        }


推荐答案

这并不困难。解决方案可以通过以下实现来实现:

This is not that difficult. The solution can be arrived at with an implementation like this :

<table>
<%
for ( int i =0; i < timeSize ; i++)
{
out.println(resource[i]);
out.println(itimespend[i]);
out.println(icostspend[i]);
totalcost += itimespend[i] * icostspend[i];     
%>

<tr>
<td> <%=resource[i]%></td>
<td><%=itimespend[i]%> </td>
<td> <%=icostspend[i]%></td>
</tr>

<%       
}
%>

</table>

将表标记保持在一边,以免每次都循环它并为每个表创建一个不同的表环。这还没有经过测试,但我认为你会从这个中得到基本的想法。

Keep the table tag out side so as not to loop it every time and create a different table with every loop. This has not been tested, but I think you will get the basic idea from this one .

这篇关于如何在jsp中显示表中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆