0

below is my code in jsp

<c:forEach var="list" items="${historyList}" varStatus="iter">
<tr>
<td>${list[0]}</td>
<td>${list[1]}</td>
<td>${list[2]}</td>
</tr>
</c:forEach>

The problem is the above code is giving the list of items correctly.But each value is repeated 6 times.

Output:

 0.456 1234 OK
 0.456 1234 OK
 0.456 1234 OK
 0.456 1234 OK
 0.456 1234 OK
 0.456 1234 OK
 1.209 3457 YES
 // this above row is also 6 times repeating

I am getting all the values but repeatedly getting like above.Please solve my problem.Thank you.

4

1 回答 1

1

它已经在迭代列表,因此无需通过特定位置访问数组的所有项目${list[0]}${list[1]},只需访问当前的迭代项,如下例所示:

<c:forEach var="item" items="${historyList}" varStatus="iter">
<tr>
<td>${item}</td>
</tr>
</c:forEach>

更新

您的代码看起来不错,因为 historyList 的项目是数组类型。我认为问题在于 historyList 有重复的项目。

于 2013-06-27T06:27:14.567 回答