今天代碼寫錯了,自己看了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()。