如何使用Spring Security在login.jsp页面显示登录错误消息? [英] How to display login error message at login.jsp page using Spring Security?

查看:487
本文介绍了如何使用Spring Security在login.jsp页面显示登录错误消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring Security。我想在 login.jsp 上显示登录错误消息,例如登录失败或帐户锁定。

解决方案

只需配置 authentication-failure-url

code>到 Servlet ,并从该servlet设置一个属性,如

 了request.setAttribute( 的errorMessage,putYourMessageHere); 

并将此请求转发到登录页面。



或提供



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



检查jsp上的参数

  $ {param.authFailed} 

并有条件地打印消息


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 ?

解决方案

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

这篇关于如何使用Spring Security在login.jsp页面显示登录错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆