Struts 2 doesn't do division when the value is double?

I have a very strange 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 big fat 0.

the property tag always outputs Integer, even when the computed value is double. How can I change this?

+1


source to share


1 answer


You are doing integer arithmetic because your inputs are integers, not doubles: two divisions by four zero for integers. Try the following:

<s:property value="%{2.0/4.0}"/>

      



instead.

+4


source







All Articles