Spring自定义JSF登录页面,老是“凭证错误" [英] Spring custom JSF login page, always "Bad credentials"
本文介绍了Spring自定义JSF登录页面,老是“凭证错误"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 JSF 登录页面来使用 Spring 安全性.我环顾四周寻找了许多示例,但没有一个有效.每次我尝试使用 JSF 页面登录时,我的服务器日志中都会收到错误凭据"警告.
Spring-Security.xml
<http auto-config="true"><intercept-url pattern="/Login.xhtml*" access="IS_AUTHENTICATED_ANONYMOUSLY"/><intercept-url pattern="/**/*.css*" access="IS_AUTHENTICATED_ANONYMOUSLY"/><intercept-url pattern="/**/*.js*" access="IS_AUTHENTICATED_ANONYMOUSLY"/><intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN"/><form-login login-page="/Login.xhtml" default-target-url="/Secure.xhtml"authentication-failure-url="/Login.xhtml"/></http><认证管理器><身份验证提供者><用户服务><user name="admin" authority="ROLE_ADMIN" password="admin"/></用户服务></authentication-provider></authentication-manager></beans:beans>
applicationContext.xml
登录.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"xmlns:h="http://java.sun.com/jsf/html"xmlns:f="http://java.sun.com/jsf/core"xmlns:ui="http://java.sun.com/jsf/facelets"><h:head></h:head><身体><h:形式><h:outputLabel value="username" for="j_username"style="float:left"/><h:inputText id="j_username" style="float:left"/><h:outputLabel value="password" for="j_password"style="float:left; clear:both"/><h:inputSecret id="j_password" style="float:left"/><h:commandButton value="登录"actionListener="#{loginBean.login}" style="float:left;clear:both"/></h:form><h:messages style="float:left;clear:both"/>