解决思路是将response的header中的X-Frame-Options项的值改为SAMEORIGIN
在Spring Boot中,可以直接改全局设置.and().headers().frameOptions().sameOrigin()
@Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .mvcMatchers("/").permitAll().anyRequest().authenticated() .antMatchers("/**").hasRole("LOGIN") .and() .formLogin().loginPage("/login").loginProcessingUrl("/login").permitAll() .and().headers().frameOptions().sameOrigin() .and().csrf().disable() ; }