Velocity 页面加减运算

需在VM页面中进行加减运算,如

1
$!row.buyNum - $!row.sellNum

在页面上打印出来就是 

3-0

然后不知道怎么用Velocity进行页面的加减运算,问了一下度娘,也找到答案

1
#set($tihuo=$!row.buyNum - $!row.sellNum)
1
是自己在页面随意定义的变量,用来保存计算结果的,然后直接在页面上写上下面的代码就行了
1
$tihuo

也可以 这样 #set(i=math.sub($velocityCount,1))

 

1
2
3
4
5
6
7
8
9
10
11
<!-- $math.add("10","4") 14 $math.sub("100","20") 80 $math.mul("11","7")
    77 $math.div("100","5") 20 $math.idiv("100","5") 20 $math.pow("2","5") 32
    $math.mod("13","5") 3 $math.max("99","16") 99 $math.min("99","16") 16 $math.abs("-99")
    99 \$math.cell("99.26") $math.cell("99.26") $math.floor("99.26") 99 $math.random
    0.7663665545444911 $math.random("1","10") 2 $math.roundTo("2","5") 5.0 $math.toInteger("15")
    15 $math.toDouble("15") 15.0 $math.toNumber("15") 15 -->
<tool>
    <key>math</key>
    <scope>application</scope>
    <class>org.apache.velocity.tools.generic.MathTool</class>
</tool>

 

posted @   锐洋智能  阅读(344)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 解决跨域问题的这6种方案,真香!
· Windows 提权-UAC 绕过
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示