How to display login error message at login.jsp page using Spring Security?

后端 未结 1 1036
抹茶落季
抹茶落季 2021-01-28 01:44

I am using Spring Security. I want to display login error message on login.jsp such as login failed or account locked. How can I display such message on login page

相关标签:
1条回答
  • 2021-01-28 02:27

    Just configure authentication-failure-url to a Servlet and set an attribute from that servlet like

    request.setAttribute("errorMessage",putYourMessageHere);
    

    and forward this request to login page.

    Or provide

    authentication-failure-url as login.jsp?authValid=false

    check for the param on jsp

    ${param.authFailed}
    

    and print the message conditionally

    0 讨论(0)
提交回复
热议问题