JSF2.0空白输入字段未设置为NULL [英] JSF2.0 Blank Input field in is not setting as NULL
问题描述
我有一个支持bean,其中filelds是Long,Double,Integer,String
当我没有在输入字段中指定任何内容时,它将Long,Integer和Double取为零而不是null。我正在使用tomcat来部署我的应用程序。有什么解决方案吗?我尝试了以下上下文参数,但它不起作用。
I have a backing bean where filelds are Long , Double , Integer , String When I am not specifying anything in input field it is taking as zero for Long, Integer and Double instead of null. I am using tomcat to deploy my app. Is there any solution? I have tried the following context parameter, but it does not work.
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
推荐答案
将以下VM参数添加到Tomcat启动选项。
Add the following VM argument to Tomcat startup options.
-Dorg.apache.el.parser.COERCE_TO_ZERO=false
您还需要确保您已声明 faces-config.xml
符合JSF 2.0规范。
You also need to ensure that you've declared faces-config.xml
conform the JSF 2.0 specification.
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<!-- Your config here -->
</faces-config>
否则将无法激活JSF 2.0特定设置/功能。
Otherwise JSF 2.0 specific settings/features won't be activated.
这篇关于JSF2.0空白输入字段未设置为NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!