subtraction is not working with velocity template

我们两清 提交于 2019-12-20 02:39:09

问题


I have this code in velocity html

<html>



#set ($Total1 = 0.0)
#set ($Total2 = 3.0)
#set ($Total3 = $Total2 -$Total1)
$Total3

</html>

The $Total3 is not getting displayed. In fact the subtraction is not working. Can anyone please help me on this


回答1:


I just tried that example in Velocity 1.6 and it worked fine.

Two possible things that might be causing problems.

(1) Your example is not copied correctly. If a dash is next to an identifier, it becomes part of the identifier. So this example would fail, since the "-" sign is actually part of the Total2 identifier.

#set ($Total3 = $Total2- $Total1)

(2) You are using a very old version of Velocity. Floating point numbers were legal syntax beginning with Velocity 1.5. (The current version is 1.7). Before that point, integers were the only number type allowed.



来源:https://stackoverflow.com/questions/15448108/subtraction-is-not-working-with-velocity-template

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!