EL表达式:将null作为BigDecimal字段的值传递 [英] EL expression: passing null as value of BigDecimal field
问题描述
我的课程有 BigDecimal
属性。当我绑定它EL表达式并传递null - valueExpression.set(context,null)
时,属性的新值变为 BigDecimal.ZERO
。
I have class with BigDecimal
property. When I bind to it EL expression and passing null - valueExpression.set(context, null)
, new value of property becomes to be BigDecimal.ZERO
.
有没有办法将null传递给 BigDecimal
字段而不将其转换为零?
Is there any way to pass null to BigDecimal
field without converting it to zero?
推荐答案
您似乎正在运行至少版本6.0.16的Tomcat或者像JBoss AS那样的分支。 Tomcat内置的Apache EL解析器确实会为所有扩展的 数
。您需要添加以下VM参数来禁用此行为(这确实不直观,但不幸的是严格按照EL规范):
You seem to be running Tomcat of at least version 6.0.16 or a fork of it like JBoss AS. Tomcat's builtin Apache EL parser will indeed do that for all classes extending Number
. You need to add the following VM argument to disable this behaviour (which is indeed unintuitive, but unfortunately strictly as per the EL spec):
-Dorg.apache.el.parser.COERCE_TO_ZERO=false
另请参见 JSP / EL规范问题184 和 Tomcat issue 42385 。
这篇关于EL表达式:将null作为BigDecimal字段的值传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!