Spring security 要插入数据库的AuthenticationFilter

Spring security 要插入数据库的AuthenticationFilter,spring-security,Spring Security,我正在实现一个支持SpringSecurity的web应用程序。 我现在使用PostgreSQL数据库来存储用户及其凭据。 该应用程序的一个要求是每次用户登录时都更新用户表(特别是最后一次登录列)。 我尝试实现一个LoginController扩展UsernamePasswordAuthenticationFilter,因此每次调用successfulAuthentication方法时,都会更新最后一个登录列 这是我的applicationContext.xml 选择username、pass

我正在实现一个支持SpringSecurity的web应用程序。 我现在使用PostgreSQL数据库来存储用户及其凭据。 该应用程序的一个要求是每次用户登录时都更新用户表(特别是最后一次登录列)。 我尝试实现一个LoginController扩展UsernamePasswordAuthenticationFilter,因此每次调用successfulAuthentication方法时,都会更新最后一个登录列

这是我的applicationContext.xml


选择username、password、enabled、salt from username=?

LoginController类:

包安全;
//进口
@控制器
公共类LoginController扩展UsernamePasswordAuthenticationFilter{
@自动连线
AuthenticationManager AuthenticationManager;
公共登录控制器(){
超级();
System.out.println(“LoginController.LoginController”);
}
@凌驾
受保护的void successfulAuthentication(HttpServletRequest请求、HttpServletResponse响应、FilterChain链、Authentication authResult)引发IOException、ServletException{
super.successfulAuthentication(请求、响应、链、authResult);
System.out.println(“更新数据库”);
}
}

问题是从未调用LoginController筛选器,因此从未插入数据库。 我很确定我犯了一个配置错误,但我对配置感到混乱和困惑:在哪里设置过滤器/提供者,等等

有人能发现我做错了什么吗?
非常感谢您。

我想提出一种不同的方法,在成功登录后使用处理程序。
在安全xml中:


...
...
课程内容如下:

公共类RedirectAfterLogin扩展了SavedRequestStataWareAuthenticationSuccessHandler{
验证成功时公共无效(HttpServletRequest请求,
HttpServletResponse(响应、身份验证)
抛出ServletException、IOException{
//在这里做你需要的
}
}