[英]Rounding Up or Down in Velocity
I'd say you could work with MathTool.roundToInt()
and adding/subtracting 1, but it should also be possible to provide an object with your methods that might provide what you need.我想说您可以使用MathTool.roundToInt()
并加/减 1,但也应该可以为 object 提供您可能需要的方法。
Also have a look at Velocity Tools 2.0 whose MathTool has methods floor() and ceil().还可以查看Velocity Tools 2.0 ,其MathTool具有方法 floor() 和 ceil()。
I recommend the Tools 2.0 MathTool for greatest type flexibility, but Velocity Engine's 1.6+ support static methods by putting the class itself into the context.我推荐 Tools 2.0 MathTool 以获得最大的类型灵活性,但 Velocity Engine 的 1.6+ 通过将 class 本身放入上下文来支持 static 方法。 So the quick and easy solution is:因此,快速简便的解决方案是:
context.put("Math", Math.class); context.put("数学", Math.class);
$Math.ceil($foo) $Math.floor($bar) $Math.ceil($foo) $Math.floor($bar)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.