Java SpringSecurity:在什么时候我才知道用户登录了?
我使用spring安全性和基于URL的拦截器来保护我的应用程序。用户登录后,我可以在哪些类/哪些点进行自定义处理 我特别想保存用户上次登录的日期,但我不知道如何实现这一点Java SpringSecurity:在什么时候我才知道用户登录了?,java,jakarta-ee,spring-security,Java,Jakarta Ee,Spring Security,我使用spring安全性和基于URL的拦截器来保护我的应用程序。用户登录后,我可以在哪些类/哪些点进行自定义处理 我特别想保存用户上次登录的日期,但我不知道如何实现这一点 感谢您的帮助。 您可以考虑实现接口。 然后,您将专门听音乐 然后,您可以保留用户的登录 可能的示例代码: public void onApplicationEvent(ApplicationEvent event) { if (event instanceof AuthenticationSuccessEvent)
感谢您的帮助。
您可以考虑实现接口。
然后,您将专门听音乐 然后,您可以保留用户的登录 可能的示例代码:public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof AuthenticationSuccessEvent) {
try {
AuthenticationSuccessEvent authenticationSuccessEvent = (AuthenticationSuccessEvent) event;
Authentication authentication = authenticationSuccessEvent.getAuthentication();
//Persist your user's login here.
} catch (Exception e) {
// Handle exception as needed.
}
}
}
可以考虑实现接口。
然后,您将专门听音乐 然后,您可以保留用户的登录 可能的示例代码:public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof AuthenticationSuccessEvent) {
try {
AuthenticationSuccessEvent authenticationSuccessEvent = (AuthenticationSuccessEvent) event;
Authentication authentication = authenticationSuccessEvent.getAuthentication();
//Persist your user's login here.
} catch (Exception e) {
// Handle exception as needed.
}
}
}