原因:SpringSecrity默认开启CSRF保护
解决方案:禁用CSRF
在Security的配置里面添加:
http.csrf().disable();
比如:
@Override protected void configure( HttpSecurity http) throws Exception { http.csrf().disable(); http.authorizeRequests() .antMatchers("/**").permitAll() .anyRequest().authenticated() .and() .httpBasic(); }
方法2:重写CSRF保护策略
没有尝试。
摘抄于(1条消息) Spring Boot使用Spring Security POST无法访问解决方案_程序新视界的博客-CSDN博客