Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use foreach in struts

I have this struts code where I am using forEach-

<c:forEach items="${reviewList}" var="reviewListId">
<tr>
   <td colspan="6" class="we_have"><c:out value="${reviewListId}" />
   </td>
</tr>

I have added this taglib

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>

But in place of forEach tag showing an error that is-

According to TLD or attribute directive in tag file, attribute items does not accept any expressions

but in place of tag lib its not showing any error that means its supporting this tag lib but don't know why its not supporting forEach tag.

like image 219
Khoyendra Pande Avatar asked Oct 09 '22 07:10

Khoyendra Pande


2 Answers

try <%@ taglib uri="http://java.sun.com/jsp/jstl/core prefix="c"%>

like image 177
Shahzeb Avatar answered Oct 11 '22 20:10

Shahzeb


I am not knowing more about the issue without seeing the code but if its not working then another altenative which you may use is struts Iterator

Iterator will iterate over a value. An iterable value can be any of: java.util.Collection, java.util.Iterator

http://struts.apache.org/2.0.14/docs/iterator.html

like image 23
Hemant Metalia Avatar answered Oct 11 '22 20:10

Hemant Metalia