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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With