EL expression: passing null as value of BigDecimal field

☆樱花仙子☆ 提交于 2019-12-06 11:15:38

问题


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.

Is there any way to pass null to BigDecimal field without converting it to zero?


回答1:


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

See also JSP/EL spec issue 184 and Tomcat issue 42385.



来源:https://stackoverflow.com/questions/9770401/el-expression-passing-null-as-value-of-bigdecimal-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!