解决iframe 请求security出现X-Frame-Options

在开发SpringSecurity配置的项目时,返回带有iframe的页面时,无法显示。

报错截图:

打开页面工具看到提示

Refused to display in a frame because it set 'X-Frame-Options' to 'DENY'

>>>>> Springboot 2.x 要在继承了 WebSecurityConfigurerAdapter 的配置类中配置。

结合SpringBoot只要在页面访问控制的配置中加上


   
   
  1. http
  2.   .authorizeRequests().antMatchers( "/login", "/login-error", "/401", "/css/**", "/js/**").permitAll()
  3.   .and().formLogin().loginPage( "/login" ).failureUrl( "/login-error" ).successForwardUrl( "/index")
  4.   .and().headers().frameOptions(). disable()//防止iframe内容无法显示
  5.   .and().exceptionHandling().accessDeniedPage( "/401" )
  6.   .and().authorizeRequests().anyRequest().authenticated();
  7. 插入.and().headers().frameOptions(). disable()//防止iframe内容无法显示,解决问题!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值