velocity做除法之后,小数点一长串:
结果为:
#set($result = 12*100.0 / 13.0)
$result%
结果为:
92.3076923076923%
要保留小数点后两位,可以这样:
#set($string = "92.3076923076923")
#set($stringList = $stringUtil.split($string,"."))
#set($strSize = $stringList.size())
#if($strSize==2)
#set($subStr = $stringList.get(1))
#set($subStrSize = $subStr.length())
#if($subStrSize>2)
$stringList.get(0).$subStr.substring(0,2)
#else
$stringList.get(0).$subStr
#end
#else
$string
#end
#end