I'm trying to access a map using OGNL, and I can't really access the map using the iterator var, but I can access it using the status.
Basically, this works:
开发者_运维问答<s:iterator value="categories" var="citem" status="stat">
<s:property value='catColors[#stat.count]' />
<s:property value='#citem.id]' />
</s:iterator>
This won't work:
<s:iterator value="categories" var="citem" status="stat">
<s:property value='catColors[#citem.id]' />
</s:iterator>
I can't really find out why. Any help is appreciated :)
Try this.
<s:iterator value="categories" var="citem" status="stat">
<s:property value='catColors[[0].id]' />
</s:iterator>
In struts [0] gets the current iterated value on the stack, which in your example would be the same as the "citem".
I am guessing that you are trying to get the catColors[] indexed at "id".
精彩评论