将以下过滤器添加到WebSecurityConfigurerAdapter以从请求中读取用户名参数:
@Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().anyRequest().authenticated().and().formLogin().and().addFilterBefore(new Filter() { public void init(FilterConfig filterConfig) throws ServletException { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (request.getParameter("username")!=null) System.out.println(request.getParameter("username")); chain.doFilter(request, response); } public void destroy() { } }, UsernamePasswordAuthenticationFilter.class); }