减法不适用于速度模板 [英] subtraction is not working with velocity template

查看:28
本文介绍了减法不适用于速度模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在速度 html 中有这个代码

I have this code in velocity html

<html>



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

</html>

$Total3 未显示.事实上,减法是行不通的.任何人都可以帮我解决这个问题

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

推荐答案

我刚刚在 Velocity 1.6 中尝试了该示例,并且效果很好.

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

可能导致问题的两种可能情况.

Two possible things that might be causing problems.

(1) 您的示例没有正确复制.如果破折号位于标识符旁边,则它成为标识符的一部分.所以这个例子会失败,因为-"号实际上是 Total2 标识符的一部分.

(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) 您使用的是非常旧版本的 Velocity.浮点数是从 Velocity 1.5 开始的合法语法.(当前版本是 1.7).在此之前,整数是唯一允许的数字类型.

(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.

这篇关于减法不适用于速度模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆