spring_security_last_username

China☆狼群 提交于 2019-12-25 03:34:49

问题


Can we access "spring_security_last_username" form the Controller instead of jsp?


回答1:


SPRING_SECURITY_LAST_USERNAME is a session attribute, therefore you can access it from the controller like any session attribute:

public ModelAndView controller(..., Session s) {
    String lastUsername = s.getAttribute("SPRING_SECURITY_LAST_USERNAME");
    ...
}



回答2:


I just want to add that the SPRING_SECURITY_LAST_USERNAME_KEY is deprecated. As mentioned in its deprecation note, you should use your custom failureHandler to retain any user information.



来源:https://stackoverflow.com/questions/5537252/spring-security-last-username

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!