开发者社区 问答 正文

在spring boot项目中出现不能加载iframe 页面-java报错

在spring boot项目中出现不能加载iframe 页面报一个"Refused to display 'http://......' in a frame because it set 'X-Frame-Options' to 'DENY'. "错误

展开
收起
montos 2020-05-28 16:08:29 1010 分享 版权
1 条回答
写回答
取消 提交回答
  •   解决:因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);
          
    }
    
    2020-05-28 16:27:37
    赞同 展开评论