EL表达式:将null作为BigDecimal字段的值传递 [英] EL expression: passing null as value of BigDecimal field

查看:1134
本文介绍了EL表达式:将null作为BigDecimal字段的值传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的课程有 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆