2011-05-26 111 views
0

我正在使用Spring Security。我想在login.jsp上顯示登錄錯誤消息,例如登錄失敗或帳戶鎖定。我如何在登錄頁面上顯示此類消息?如何使用Spring Security在login.jsp頁面顯示登錄錯誤消息?

+0

您使用的春季安全? – 2011-05-26 13:21:08

+0

@Jigar:是的,我使用彈簧安全。在我的應用程序中,身份驗證通過ldap完成。我想顯示來自message.properties文件的登錄失敗,帳戶鎖定消息。爲此我已經寫下'AuthenticationFailureBadCredentialsEvent',所以在這種情況下我增加了數據庫中的計數器。遞增計數器後,我想從屬性文件中讀取錯誤消息,並在登錄頁面上顯示此消息。我怎麼能顯示這樣的消息? – Raje 2011-05-26 13:48:22

回答

3

只是配置authentication-failure-urlServlet,並設置從該servlet的屬性一樣

request.setAttribute("errorMessage",putYourMessageHere); 

並轉發此請求到登錄頁面。

或提供

authentication-failure-urllogin.jsp?authValid=false

檢查對JSP

${param.authFailed} 

帕拉姆並打印消息有條件

相關問題