带有迭代器 var 的 OGNL 动态访问映射
我正在尝试使用 OGNL 访问地图,但我无法真正使用迭代器变量访问地图,但我可以使用状态访问它。
基本上,这有效:
<s:iterator value="categories" var="citem" status="stat">
<s:property value='catColors[#stat.count]' />
<s:property value='#citem.id]' />
</s:iterator>
这行不通:
<s:iterator value="categories" var="citem" status="stat">
<s:property value='catColors[#citem.id]' />
</s:iterator>
我真的无法找出原因。如有任何帮助,我们将不胜感激:)
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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个。
在 struts [0] 中获取堆栈上的当前迭代值,在您的示例中该值与“citem”相同。
我猜测您正在尝试获取以“id”索引的 catColors[] 。
Try this.
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".