0
我相信您将能够帮助我解决以下问题。JAAS + Primefaces:登录表单不会重定向到错误页面
我开始使用Java EE和Primefaces进行冒险,需要一些帮助来理解/解决问题。
所以我创建了使用JAAS和登录模块如下配置:
的web.xml
<login-config>
<auth-method>FORM</auth-method>
<realm-name>authRealm</realm-name>
<form-login-config>
<form-login-page>/public/login.xhtml</form-login-page>
<form-error-page>/public/loginError.xhtml</form-error-page>
</form-login-config>
</login-config>
login_page_1.xhtml
<p:panel header="Login From">
<form method="POST" action="j_security_check">
Username: <input type="text" name="j_username" />
Password: <input type="password" name="j_password" />
<br />
<input type="submit" value="Login" />
<input type="reset" value="Reset" />
</form>
</p:panel>
这种配置工作好了但是我” m使用primefaces作为前端框架我想使页面看起来更好。我发现了以下决议:
login_page_2.xhtml
<p:panel header="Login From">
<h:form id="loginForm" onsubmit="document.getElementById('loginForm').action='j_security_check';" prependId="false">
<p:panelGrid columns="2">
<p:outputLabel for="j_username" value="Email" />
<p:inputText id="j_username" />
<p:outputLabel for="j_password" value="Passwort" />
<p:password id="j_password"/>
<p:commandButton id="login" value="Login" ajax="false" />
</p:panelGrid>
</h:form>
</p:panel>
的问题是,当我使用login_page_1.xhtml
,把错误的凭据(错误的用户名/密码),我得到了重定向到errorLogin.xhtml
然而,当(这是可取的行为)我用login_page_2.xhtml
我得到以下erorr
An Error Occurred:
Index: 0, Size: 0
Warning: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception
Warning: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception
FATAL: JSF1073: javax.faces.FacesException caught during processing of RESTORE_VIEW 1 : UIComponent-ClientId=, Message=Unexpected error restoring state for component with id j_idt6. Cause: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0.
FATAL: Unexpected error restoring state for component with id j_idt6. Cause: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0.
javax.faces.FacesException: Unexpected error restoring state for component with id j_idt6. Cause: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0.
我会感谢任何帮助!
在此先感谢。
看看这个http://stackoverflow.com/a/13620288/3324704 – fonkap 2014-11-23 15:59:46
感谢队友,但我用这个答案,它不是在100%的工作。 – Silwest 2014-11-23 16:17:43
也许您应该考虑改为使用程序化登录 – kolossus 2014-11-24 01:33:09