首页 > spring boot整合spring security,使用默认的登录页面可以认证,使用自定义的登录页面登录时403

spring boot整合spring security,使用默认的登录页面可以认证,使用自定义的登录页面登录时403

把配置信息.loginPage注释掉使用自带的登录页面可以进行身份认证,但是我把登录页面抽出来单独访问的时候总是报403

配置信息:

 @Override
    public void configure(HttpSecurity http) throws Exception{
        http.authorizeRequests()
                .anyRequest().authenticated()
                .antMatchers("/index.html").permitAll()
                .and()
                .formLogin()
                .usernameParameter("username")
                .passwordParameter("password")
                .loginProcessingUrl("/loginValid")
                .loginPage("/login")
                .failureUrl("/login?error")
                .permitAll()
                .and()
                .logout().permitAll();
    }

使用post请求工具报错403:

请问应该如何配置才能正常认证呢,登录页面要和项目分离开

服务器上login.html code:

【热门文章】
【热门文章】