shan
shan

Reputation: 1

spring_security_last_username

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

Upvotes: 0

Views: 3259

Answers (2)

Ritesh
Ritesh

Reputation: 7522

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.

Upvotes: 0

axtavt
axtavt

Reputation: 242786

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");
    ...
}

Upvotes: 2

Related Questions