Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring explict身份验证调用未调用自定义处理程序_Java_Spring_Spring Security - Fatal编程技术网

Java Spring explict身份验证调用未调用自定义处理程序

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

要求是,当提交JSP页面时,操作如下 “测试/登录”,然后下面的方法将调用,它将检查有效性,如果 成功,它必须重定向到CustomSuccess hanlder,但它不工作

控制器:

@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)