在开发SpringSecurity配置的项目时,返回带有iframe的页面时,无法显示。
报错截图:
打开页面工具看到提示
Refused to display in a frame because it set 'X-Frame-Options' to 'DENY'
>>>>> Springboot 2.x 要在继承了 WebSecurityConfigurerAdapter 的配置类中配置。
结合SpringBoot只要在页面访问控制的配置中加上
-
http
-
.authorizeRequests().antMatchers(
"/login",
"/login-error",
"/401",
"/css/**",
"/js/**").permitAll()
-
.and().formLogin().loginPage(
"/login" ).failureUrl(
"/login-error" ).successForwardUrl(
"/index")
-
.and().headers().frameOptions().
disable()//防止iframe内容无法显示
-
.and().exceptionHandling().accessDeniedPage(
"/401" )
-
.and().authorizeRequests().anyRequest().authenticated();
-
插入.and().headers().frameOptions().
disable()//防止iframe内容无法显示,解决问题!