Spring Boot 出现 in a frame because it set 'X-Frame-Options' to 'DENY'

Posted 不再_单纯

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring Boot 出现 in a frame because it set 'X-Frame-Options' to 'DENY'相关的知识,希望对你有一定的参考价值。

在spring boot项目中出现不能加载iframe

页面报一个"Refused to display ‘http://......‘ in a frame because it set ‘X-Frame-Options‘ to ‘DENY‘. "错误

解决方式:

因spring Boot采取的java config,在配置spring security的位置添加:

@Override
protected void configure(HttpSecurity http) throws Exception {
       http.headers().frameOptions().disable();
     http
      .csrf().disable();
     http
      .authorizeRequests()
             .anyRequest().authenticated();
      
      http.formLogin()
          .defaultSuccessUrl("/platform/index",true)
          .loginPage("/login")
          .permitAll()
        .and()
          .logout()
           .logoutUrl("/logout");
      
      http.addFilterBefore(wiselyFilterSecurityInterceptor(),FilterSecurityInterceptor.class);
        
      
}



转载请说明 出处 谢谢!!!




以上是关于Spring Boot 出现 in a frame because it set 'X-Frame-Options' to 'DENY'的主要内容,如果未能解决你的问题,请参考以下文章

Spring Boot MQTT Too many publishes in progress错误的解决方案

spring boot注入error,Consider defining a bean of type 'xxx' in your configuration问题解决方案

Spring Boot 踩坑之路之 Configuration Annotation Proessor not found in classpath

spring-boot整合freemarker 出现404

spring-boot整合freemarker 出现404

Spring Boot启动时出现WARN:No MyBatis mapper was found in