今天代码写错了,自己看了1个半小时,啥都没发现,还是找的同学才看出来。
// @Override // protected void configure(HttpSecurity http) throws Exception { // http.authorizeRequests() // .anyRequest().authenticated() // .and() // .formLogin().loginPage("/login") // .defaultSuccessUrl("/").permitAll() // .and() // .logout().permitAll(); // http.cors().disable(); // } @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .anyRequest().authenticated() .and() .formLogin().loginPage("/login") .defaultSuccessUrl("/").permitAll() .and() .logout().permitAll(); http.csrf().disable(); }
http.csrf().disable()写成了http.cors().disable()。