Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Validation FacesValidator不工作_Validation_Jsf_Jsf 2 - Fatal编程技术网

Validation FacesValidator不工作

Validation FacesValidator不工作,validation,jsf,jsf-2,Validation,Jsf,Jsf 2,您好,我在通过单独的验证器实例验证html组件时遇到了一个问题 永远不会调用验证!系统永远不会写入控制台 我已经尝试过重新部署、更新项目、清理并重新启动、重新安装glassfish工具、重新安装glassfish、重新安装eclipse 这是我的项目设置: 注册。xhtml: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xht

您好,我在通过单独的验证器实例验证html组件时遇到了一个问题

永远不会调用验证!系统永远不会写入控制台

我已经尝试过重新部署、更新项目、清理并重新启动、重新安装glassfish工具、重新安装glassfish、重新安装eclipse

这是我的项目设置:

注册。xhtml:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
    xmlns:jsf="http://xmlns.jcp.org/jsf">
<h:head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Registration</title>
    <h:outputStylesheet library="css" name="stylesheet.css" target="head" />
    <h:outputScript library="js" name="jquery-3.1.1.min.js" target="head" />
    <h:outputScript library="js" name="jquery-ui-1.12.1.min.js"
        target="head" />
</h:head>
<h:body>
        <h:form prependId="false">              
        <h:inputSecret id="password" binding="#{localPasswordComponent}"  p:placeholder="Password"
                value="#{registrationBean.password}" required="true"
                requiredMessage="Please enter password"
                validatorMessage="Please enter at least 8 characters">
                <f:validateLength minimum="8" />
            </h:inputSecret>
            <h:message for="password" style="color:red" tooltip="true" showSummary="true" showDetail="true"/>
            <br />

            <h:inputSecret id="confirmPassword" p:placeholder="Confirm Password"
                required="#{not empty localPasswordComponent.value}"
                requiredMessage="Please confirm password"
                validatorMessage="Passwords are not equal">
                <f:validator validatorId="equalsValidator" />
                <f:attribute name="equalsValue" value="#{localPasswordComponent.value}" />
            </h:inputSecret>
            <h:message for="confirmPassword" tooltip="true" showSummary="true" showDetail="true"/>
            <br />
            <input jsf:id="submit" name="submit" value="Register" type="submit">
                <f:ajax render="@all" listener="#{registrationBean.register}" />
            </input>
        <br />
        </h:form>
    </h:body>
</html>
package de.somepackage.validator;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

@FacesValidator(value="equalsValidator")
public class EqualsValidator implements Validator {

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        System.out.println("Wow this is called!!!!!!!!!!!!!");
        Object otherValue = component.getAttributes().get("equalsValue");

        if (value == null || otherValue == null) {
            return; // Let required="true" handle.
        }

        if (!value.equals(otherValue)) {
            FacesMessage msg =
                    new FacesMessage("Values are not equal.");
            msg.setSeverity(FacesMessage.SEVERITY_ERROR);
            throw new ValidatorException(msg);
        }
    }

}
<?xml version='1.0' encoding='UTF-8'?>

<faces-config version="2.1"
    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_1.xsd">

</faces-config>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    id="PeeDeeWebFrontend" version="3.1">
    <display-name>PeeDee</display-name>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>${webapp.projectStage}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>${webapp.partialStateSaving}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>${webapp.stateSavingMethod}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/web/*</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>web/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <context-root>/PeeDeeWebFrontend</context-root>
    <class-loader delegate="true"/>
      <jsp-config>
        <property name="keepgenerated" value="true"></property>
      </jsp-config> 
</glassfish-web-app>
faces config.xml:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
    xmlns:jsf="http://xmlns.jcp.org/jsf">
<h:head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Registration</title>
    <h:outputStylesheet library="css" name="stylesheet.css" target="head" />
    <h:outputScript library="js" name="jquery-3.1.1.min.js" target="head" />
    <h:outputScript library="js" name="jquery-ui-1.12.1.min.js"
        target="head" />
</h:head>
<h:body>
        <h:form prependId="false">              
        <h:inputSecret id="password" binding="#{localPasswordComponent}"  p:placeholder="Password"
                value="#{registrationBean.password}" required="true"
                requiredMessage="Please enter password"
                validatorMessage="Please enter at least 8 characters">
                <f:validateLength minimum="8" />
            </h:inputSecret>
            <h:message for="password" style="color:red" tooltip="true" showSummary="true" showDetail="true"/>
            <br />

            <h:inputSecret id="confirmPassword" p:placeholder="Confirm Password"
                required="#{not empty localPasswordComponent.value}"
                requiredMessage="Please confirm password"
                validatorMessage="Passwords are not equal">
                <f:validator validatorId="equalsValidator" />
                <f:attribute name="equalsValue" value="#{localPasswordComponent.value}" />
            </h:inputSecret>
            <h:message for="confirmPassword" tooltip="true" showSummary="true" showDetail="true"/>
            <br />
            <input jsf:id="submit" name="submit" value="Register" type="submit">
                <f:ajax render="@all" listener="#{registrationBean.register}" />
            </input>
        <br />
        </h:form>
    </h:body>
</html>
package de.somepackage.validator;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

@FacesValidator(value="equalsValidator")
public class EqualsValidator implements Validator {

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        System.out.println("Wow this is called!!!!!!!!!!!!!");
        Object otherValue = component.getAttributes().get("equalsValue");

        if (value == null || otherValue == null) {
            return; // Let required="true" handle.
        }

        if (!value.equals(otherValue)) {
            FacesMessage msg =
                    new FacesMessage("Values are not equal.");
            msg.setSeverity(FacesMessage.SEVERITY_ERROR);
            throw new ValidatorException(msg);
        }
    }

}
<?xml version='1.0' encoding='UTF-8'?>

<faces-config version="2.1"
    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_1.xsd">

</faces-config>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    id="PeeDeeWebFrontend" version="3.1">
    <display-name>PeeDee</display-name>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>${webapp.projectStage}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>${webapp.partialStateSaving}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>${webapp.stateSavingMethod}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/web/*</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>web/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <context-root>/PeeDeeWebFrontend</context-root>
    <class-loader delegate="true"/>
      <jsp-config>
        <property name="keepgenerated" value="true"></property>
      </jsp-config> 
</glassfish-web-app>

web.xml:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
    xmlns:jsf="http://xmlns.jcp.org/jsf">
<h:head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Registration</title>
    <h:outputStylesheet library="css" name="stylesheet.css" target="head" />
    <h:outputScript library="js" name="jquery-3.1.1.min.js" target="head" />
    <h:outputScript library="js" name="jquery-ui-1.12.1.min.js"
        target="head" />
</h:head>
<h:body>
        <h:form prependId="false">              
        <h:inputSecret id="password" binding="#{localPasswordComponent}"  p:placeholder="Password"
                value="#{registrationBean.password}" required="true"
                requiredMessage="Please enter password"
                validatorMessage="Please enter at least 8 characters">
                <f:validateLength minimum="8" />
            </h:inputSecret>
            <h:message for="password" style="color:red" tooltip="true" showSummary="true" showDetail="true"/>
            <br />

            <h:inputSecret id="confirmPassword" p:placeholder="Confirm Password"
                required="#{not empty localPasswordComponent.value}"
                requiredMessage="Please confirm password"
                validatorMessage="Passwords are not equal">
                <f:validator validatorId="equalsValidator" />
                <f:attribute name="equalsValue" value="#{localPasswordComponent.value}" />
            </h:inputSecret>
            <h:message for="confirmPassword" tooltip="true" showSummary="true" showDetail="true"/>
            <br />
            <input jsf:id="submit" name="submit" value="Register" type="submit">
                <f:ajax render="@all" listener="#{registrationBean.register}" />
            </input>
        <br />
        </h:form>
    </h:body>
</html>
package de.somepackage.validator;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

@FacesValidator(value="equalsValidator")
public class EqualsValidator implements Validator {

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        System.out.println("Wow this is called!!!!!!!!!!!!!");
        Object otherValue = component.getAttributes().get("equalsValue");

        if (value == null || otherValue == null) {
            return; // Let required="true" handle.
        }

        if (!value.equals(otherValue)) {
            FacesMessage msg =
                    new FacesMessage("Values are not equal.");
            msg.setSeverity(FacesMessage.SEVERITY_ERROR);
            throw new ValidatorException(msg);
        }
    }

}
<?xml version='1.0' encoding='UTF-8'?>

<faces-config version="2.1"
    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_1.xsd">

</faces-config>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    id="PeeDeeWebFrontend" version="3.1">
    <display-name>PeeDee</display-name>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>${webapp.projectStage}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>${webapp.partialStateSaving}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>${webapp.stateSavingMethod}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/web/*</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>web/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <context-root>/PeeDeeWebFrontend</context-root>
    <class-loader delegate="true"/>
      <jsp-config>
        <property name="keepgenerated" value="true"></property>
      </jsp-config> 
</glassfish-web-app>

皮迪
javax.faces.PROJECT_阶段
${webapp.projectStage}
javax.faces.PARTIAL_STATE_保存
${webapp.partialStateSaving}
javax.faces.STATE_保存方法
${webapp.stateSavingMethod}
javax.faces.VALIDATE_空_字段
真的
javax.faces.explait_EMPTY_STRING_SUBMITTED_VALUES_为_NULL
真的
Facesservlet
javax.faces.webapp.FacesServlet
1.
Facesservlet
/网/*
web/index.xhtml
glassfishweb.xml:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
    xmlns:jsf="http://xmlns.jcp.org/jsf">
<h:head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Registration</title>
    <h:outputStylesheet library="css" name="stylesheet.css" target="head" />
    <h:outputScript library="js" name="jquery-3.1.1.min.js" target="head" />
    <h:outputScript library="js" name="jquery-ui-1.12.1.min.js"
        target="head" />
</h:head>
<h:body>
        <h:form prependId="false">              
        <h:inputSecret id="password" binding="#{localPasswordComponent}"  p:placeholder="Password"
                value="#{registrationBean.password}" required="true"
                requiredMessage="Please enter password"
                validatorMessage="Please enter at least 8 characters">
                <f:validateLength minimum="8" />
            </h:inputSecret>
            <h:message for="password" style="color:red" tooltip="true" showSummary="true" showDetail="true"/>
            <br />

            <h:inputSecret id="confirmPassword" p:placeholder="Confirm Password"
                required="#{not empty localPasswordComponent.value}"
                requiredMessage="Please confirm password"
                validatorMessage="Passwords are not equal">
                <f:validator validatorId="equalsValidator" />
                <f:attribute name="equalsValue" value="#{localPasswordComponent.value}" />
            </h:inputSecret>
            <h:message for="confirmPassword" tooltip="true" showSummary="true" showDetail="true"/>
            <br />
            <input jsf:id="submit" name="submit" value="Register" type="submit">
                <f:ajax render="@all" listener="#{registrationBean.register}" />
            </input>
        <br />
        </h:form>
    </h:body>
</html>
package de.somepackage.validator;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

@FacesValidator(value="equalsValidator")
public class EqualsValidator implements Validator {

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        System.out.println("Wow this is called!!!!!!!!!!!!!");
        Object otherValue = component.getAttributes().get("equalsValue");

        if (value == null || otherValue == null) {
            return; // Let required="true" handle.
        }

        if (!value.equals(otherValue)) {
            FacesMessage msg =
                    new FacesMessage("Values are not equal.");
            msg.setSeverity(FacesMessage.SEVERITY_ERROR);
            throw new ValidatorException(msg);
        }
    }

}
<?xml version='1.0' encoding='UTF-8'?>

<faces-config version="2.1"
    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_1.xsd">

</faces-config>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    id="PeeDeeWebFrontend" version="3.1">
    <display-name>PeeDee</display-name>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>${webapp.projectStage}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
        <param-value>${webapp.partialStateSaving}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>${webapp.stateSavingMethod}</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/web/*</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>web/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <context-root>/PeeDeeWebFrontend</context-root>
    <class-loader delegate="true"/>
      <jsp-config>
        <property name="keepgenerated" value="true"></property>
      </jsp-config> 
</glassfish-web-app>

/PeeDeeWebFrontend
版本:

  • GlassFish服务器开源版本4.1.1(构建1)
  • Eclipse Jee Neon.1发行版(4.6.1)构建id:20160913-0900
  • JSF2.2.14版本15。2016年11月(原为2.1)
  • JAVA_VERSION=“1.8.0_102”OS_NAME=“Windows”OS_VERSION=“5.2” OS_ARCH=“amd64”
  • Maven 3(我想)
  • Java EE 7u2来自
我使用JavaEE7U2安装来配置我的项目

由于我对JSF、Glassfish、JSP和其他web开发工具完全不熟悉,所以我不知道为什么它不起作用,因为有几个示例建议它是这样的。有没有人能给我一个答案,或者告诉我为什么这不起作用


注意:我正在使用Glassfish工具在Eclipse中运行服务器

,因为我在自己身上找到了答案,下面的代码没有抛出运行时错误,只是一个编译器警告:

<input jsf:id="submit" name="submit" value="Register" type="submit">
    <f:ajax render="@all" listener="#{registrationBean.register}" />
</input>

将其更改为:

<h:commandButton value="Submit" action="#{registrationBean.register()}" />

这解决了我的问题,找到并调用了EqualsValidator

在“流程验证”阶段,分别应用呈现和验证程序

有些渲染是隐式的:

  • javax.faces.Boolean
  • javax.faces.Byte
  • javax.faces.Character
  • javax.faces.Short
  • javax.faces.Integer
  • javax.faces.Long
  • javax.faces.Float
  • javax.faces.Double
  • javax.faces.BigDecimal
  • javax.faces.biginger
这意味着它们将自动应用于字段。因此,如果您有一个bean属性“int”和一个绑定该属性的值输入,并在其上加上一个字母,然后提交该值,则会自动应用隐式javax.faces.Integer并抛出一个异常。此时,如果您在该输入上有一个验证器,它将永远不会被调用

例:



什么不起作用?是否调用了
System.out.println
?您是否清理、构建和重新部署了所有内容?@ImproveAnything问题是什么?您粘贴了所有代码,但忽略了问题所在。