You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:如何在Polarion Live Report页面中使用$mathTool

Polarion Live Report中$mathTool无法使用的解决办法
  • 手动实例化MathTool
    Live Report的Velocity上下文默认没加载MathTool,直接在脚本开头添加实例化代码即可:
#set($mathTool = new org.apache.velocity.tools.generic.MathTool())
#set($ratio= $mathTool.div($countIn, $countOut))
  • 用原生Velocity算术运算替代
    不想额外实例化工具的话,直接用Velocity自带的除法运算符,记得处理除数为0的情况:
#if($countOut != 0)
    #set($ratio = $countIn / $countOut)
#else
    #set($ratio = 0) # 或者根据需求设置默认值
#end

原因说明:Polarion Wiki页面默认加载了完整的Velocity Tools工具集,包含$mathTool;而Live Report为了性能,上下文更精简,默认不包含这个工具,所以需要手动处理。

内容的提问来源于stack exchange,提问作者Florian Straub

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 21:29:55