开发者

issue with JSTL Hashset

The below code is not working

<c:forEach var="row" varStatus="rowCount" begin="1" end="10">

 <c:set var="entry" scope="request" value="${session.en开发者_StackOverflowtry.mileStones[rowCount.count]}"/>
 or

<c:set var="entry" scope="request" value="${entry.mileStones[rowCount.count]}"/>

</c:forEach>

where , Entry.getMileStones ====> HashSet is properly set in action class in session scope.

getSession().setAttribute("entry", entry);

Any idea..


Some problems I see with the example provided:

  • As far as I know, JSTL and EL syntax doesn't work for sets, only maps. This makes sense, because there's no concept of retrieving the value for a key in a set (as the value is the key). Based the on the example you've provided, it looks like you might actually want the data structure to be either a list or a map.

  • It looks like you're trying to set a scoped value (entry) on the basis of the same value. Even if this will work, I doubt that it's what you want to do. Consider a different variable name for the second variable.

  • You can't iterate with a foreach without providing a collection to iterate over. There must be an items attribute with the foreach tag.


You are using different scopes. Change scope to session.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜