I am sending a list of custom objects with model, and a JSP as a view. My custom object has a property called properties and it is JSONObject. This property will have the value as
{"services":[{"name":"abcd"},{"name":"efgh"}]}
now I want to iterate through the JSONArray [{"name":"abcd"},{"name":"efgh"}]. Here is what I am doing to loop through
<c:if test="${not empty customObject.services}">
<c:forEach items="${customObject.services.getJSONArray(\"services\")}" var="Service" varStatus="rowCounterCh">
<li>${Service.name}</li>
</c:forEach>
</c:if>
But this is not able to iterate through the JSONArray. Am getting following error.
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach>
So, what should I do to iterate through the JSONArray? Pls help
For each tag should require a base interface for your items. JSONArray neither java.util.Collection nor java.util.Iterable. So For each tag implementation cannot iterate over the collection you pass into items attribute.
To solve this problem you may:
more detailed explanation