简体   繁体   English

如果值为null,则Mvel表达式评估问题

[英]Mvel Expression Evaluation Issues if value is null

Let say i have a below expression that needs to be evaluated using MVEL. 假设我有一个下面的表达式,需要使用MVEL进行评估。

( ( ( A * B ) + C ) / D ) ((((A * B)+ C)/ D)

suppose value of B is NULL, then MVEL evaluates "A * B" as FALSE. 假设B的值为NULL,则MVEL将“ A * B”评估为FALSE。 "(A * B) + C" becomes FalseC Then FalseC/D throws exception “(A * B)+ C”变为FalseC,然后FalseC / D引发异常

How to prevent this...?? 如何防止这种情况...?

As of now we solved this be below approach. 截至目前,我们解决了以下方法。 If you actually debug this in Mvel API classes, they are explicitly returning false for this particular case. 如果您实际上在Mvel API类中对此进行调试,则对于这种特殊情况,它们将显式返回false。 If Mvel can fix this, it will be good. 如果Mvel可以解决此问题,那将是很好。 But this same issue i also encountered, so what we did, we created some intelligence before executing the expression, we modified the expression and included "IF" condition to check for the fields that are null and having operator as "/" or "*", the return null. 但是我也遇到了同样的问题,所以我们做的是,在执行表达式之前创建了一些智能,修改了表达式并包含了“ IF”条件,以检查是否为空并且将运算符设置为“ /”或“ *” ”,则返回null。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM