Reputation: 31
I have an iterate and i want to calculate sum of the values like this :
<s:iterator value="myValues" status="myStatus">
<s:property value="value" />
</s:iterator>
<s:property value="total.here" />
I want to show the sum of "value" in "total.here". Sorry for my bad english. Thank you very much.
Upvotes: 3
Views: 5929
Reputation: 75896
Samuel_xL's answer is right. But, in general, if you can edit your action class, I'd advice to make the calculation there instead of doing it in jsp.
Upvotes: 1
Reputation: 19327
Assuming myValues is an array or a list of integral values accessible from your action:
<s:set var="total" value="%{0}" />
<s:iterator value="myValues">
<s:set var="total" value="%{top + #attr.total}" />
</s:iterator>
<s:property value="%{'' + #attr.total}" />
Upvotes: 4