Because size
method return type is int
and the end
attribute of <s:iterator>
eventually will be cast to Integer
you can simple add 1
to the size of array list before dividing it and you get same result as using Math.ceil
.
<s:iterator var="counter" begin="0" end="(arraylist.size()+1)/2">
</s:iterator>
BTW if you decide to enable struts.ognl.allowStaticMethodAccess
which is not recommended and use Math.ceil
method in JSP you need to indicate that you are dividing by a double value (e.g. 2d
) or it will be converted to int
before passing it to ceil
.
<s:iterator var = "counter" begin = "0"
end = "@java.lang.Math@ceil(arraylist.size()/2d)">
</s:iterator>