Jakarta ee 在xhtml登录页面上显示身份验证错误

Jakarta ee 在xhtml登录页面上显示身份验证错误,jakarta-ee,authentication,jboss,wildfly,Jakarta Ee,Authentication,Jboss,Wildfly,我已经使用wildfly安全域配置了身份验证。如果信条有效,一切都会起作用。当用户名或密码错误时,我想在login.xhtml页面上显示错误消息。我该怎么做?我正在使用primefaces来表示pre-valdiationempty字段 我的login.xhtml页面: <h:body style="background: url(resources/background.png); background-repeat: no-repeat; background-attach

我已经使用wildfly安全域配置了身份验证。如果信条有效,一切都会起作用。当用户名或密码错误时,我想在login.xhtml页面上显示错误消息。我该怎么做?我正在使用primefaces来表示pre-valdiationempty字段

我的login.xhtml页面:

<h:body
    style="background: url(resources/background.png);   background-repeat: no-repeat; background-attachment: fixed; background-position: center; ">
    <div id="loginDiv" style="margin: 0 auto;">
        <h:form id="login"
            onsubmit="document.getElementById('login').action='j_security_check';"
            prependId="false">

            <p:growl id="growl" sticky="true" showDetail="true" life="3000" />

            <p:dialog id="loginDial" header="Login page"
                widgetVar="loginDialog" width="400" height="130" visible="true"
                closable="false" draggable="false" resizable="false">
                <h:panelGrid columns="2" style="margin: 0 auto;">
                    <p:outputLabel for="j_username" value="Username:" />
                    <p:inputText id="j_username" name="j_username" required="true" />
                    <p:outputLabel for="j_password" value="Password:" />
                    <p:password id="j_password" name="j_password" required="true" />
                    <p:outputLabel value=" " />
                    <p:commandButton id="submit" value="Login" ajax="false" />
                </h:panelGrid>
            </p:dialog>
        </h:form>
    </div>
</h:body>

始终返回false。

尝试为您的登录创建一个单独的错误页面,然后将/login.xhtml?failed=true上的值更改为新页面,以查看发生的情况。我被重定向到错误页面,但在url中我只看到“j_security_check”
<login-config>
        <auth-method>FORM</auth-method>
        <realm-name>LDAPAuth realm</realm-name>
        <form-login-config>
            <form-login-page>/login.xhtml</form-login-page>
            <form-error-page>/login.xhtml?failed=true</form-error-page>
        </form-login-config>
    </login-config>
FacesContext.getCurrentInstance().isValidationFailed();