문제
Struts2에는 매우 이상한 시나리오가 있습니다.
다음을 수행 할 때 :
<s:property value="%{4/2}"/>
나는 2를 얻었다.
그러나 다음을 수행 할 때 :
<s:property value="%{2/4}"/>
나는 큰 지방 0을 얻는다.
평가 된 값이 이중 인 경우에도 속성 태그는 항상 정수를 출력합니다. 이것을 어떻게 변경할 수 있습니까?
해결책
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.
제휴하지 않습니다 StackOverflow