Java Spring explict身份验证调用未调用自定义处理程序
要求是,当提交JSP页面时,操作如下 “测试/登录”,然后下面的方法将调用,它将检查有效性,如果 成功,它必须重定向到CustomSuccess hanlder,但它不工作 控制器:Java Spring explict身份验证调用未调用自定义处理程序,java,spring,spring-security,Java,Spring,Spring Security,要求是,当提交JSP页面时,操作如下 “测试/登录”,然后下面的方法将调用,它将检查有效性,如果 成功,它必须重定向到CustomSuccess hanlder,但它不工作 控制器: @RequestMapping("test/login") public String login(Map<String, Object> model, HttpServletRequest request) { String userName = (String) request.getPar
@RequestMapping("test/login")
public String login(Map<String, Object> model, HttpServletRequest request) {
String userName = (String) request.getParameter("username");
String password = (String) request.getParameter("password");
Authentication authentication =authenticationProvider.authenticate(new UsernamePasswordAuthenticationToken(userName, password));
}
处理程序:
@Bean(name = "mainSuccessHandler")
public AuthenticationSuccessHandler mainSuccessHandler(
@Qualifier("defaultSuccessHandler") AuthenticationSuccessHandler defaultSuccessHandler
CustomAuthenticationSuccessHandler result = new CustomAuthenticationSuccessHandler();
result.addAuthenticationFailureHandler(anyRefererRequestMather(), defaultSuccessHandler);
return result;
}
您正在使用成功处理程序作为失败处理程序。试一试
.successHandler(mainSuccessHandler)
可能重复的
.successHandler(mainSuccessHandler)