开发者

OGNL dynamic access map with iterator var

开发者 https://www.devze.com 2023-03-12 04:20 出处:网络
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.

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".

0

精彩评论

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

关注公众号