struts 2 doesnt do division when value is a double?
-
05-07-2019 - |
Question
I have a very weird scenario in struts2.
When I do the following:
<s:property value="%{4/2}"/>
I get 2.
But when I do the following:
<s:property value="%{2/4}"/>
I get a big fat 0.
the property tag is always outputting an Integer even when the evaluated value is a double. How can I change this?
Solution
You're doing integer arithmetic because your inputs are integers, not doubles: two divided by four is zero for integers. Try this:
<s:property value="%{2.0/4.0}"/>
instead.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow