将空数字转换为null [英] Convert empty number as null

查看:120
本文介绍了将空数字转换为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能告诉我的JSF实现将空数字转换为null. 到目前为止,我总是得到0(对应的复数类型).
对于空字符串,有 javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL ,但我找不到数字的任何内容.顺便说一句:不,我不能使用虚拟机参数: -Dorg.apache.el.parser.COERCE_TO_ZERO = false

is there a possibility to tell my JSF-implementation to convert empty numbers as null. So far I always get 0 (of the corresponging complex-type).
For empty strings there is javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL, but I couldn't find anything for numbers. By the way: No, I can't use the vm-argument: -Dorg.apache.el.parser.COERCE_TO_ZERO=false

自定义数字转换器是我唯一的可能性吗?

Is a custom-numberconverter my only possibility?

推荐答案

不,我无法使用vm参数:-Dorg.apache.el.parser.COERCE_TO_ZERO = false

问题出在服务器使用的EL实现中,而不是JSF中.您确实需要使用VM参数.如果您不能使用它,则只能通过将Tomcat降级到6.0.15或更早版本,或者用例如Glassfish替换服务器来解决您的问题.引入改进的" EL强制行为是Tomcat 6.0.16.

The problem is in EL implementation used by the server, not in JSF. You really need to use the VM argument. If you can't use it then your problem can't be solved by other way than downgrading Tomcat to 6.0.15 or older, or replacing the server by for example Glassfish. It was Tomcat 6.0.16 when this "improved" EL coercion behaviour was introduced.

如果您详细说明了无法使用它的确切原因(这对我来说至少没有意义),那么我们也许可以提出如何真正使用它的方法.例如,如果不了解如何设置VM参数,请这样说.或者,如果由于它是由第三方维护的服务器而不允许您将VM参数添加到启动脚本中,请这样说.这两个问题都可以解决,因此您可以正确使用VM参数.

If you elaborate the exact reason why you can't use it (it makes at least no sense to me), then we may be able to propose ways how to really use it. For example, if it's ignorance how to set a VM argument, then say so. Or if you're not allowed to add a VM argument to startup script because it's a 3rd party maintained server, then say so. Both problems can be solved so that you can use the VM argument rightly.

这篇关于将空数字转换为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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