How to display login error message at login.jsp pa

2019-03-06 02:54发布

问题:

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:

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