JSF2.0空白输入字段未设置为NULL

Arv*_*ind 6 java jsf jsf-2

我有一个支持Bean其中filelds长,双,整数,字符串当我不指定在输入栏的东西,它以零时间不长,整数和双精度,而不是空.我正在使用tomcat来部署我的应用程序.有什么解决方案吗?我尝试了以下上下文参数,但它不起作用.

<context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)

Bal*_*usC 7

将以下VM参数添加到Tomcat启动选项.

-Dorg.apache.el.parser.COERCE_TO_ZERO=false

您还需要确保已声明faces-config.xml符合JSF 2.0规范.

<?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>
Run Code Online (Sandbox Code Playgroud)

否则,将不会激活JSF 2.0特定的设置/功能.