在开发SpringSecurity5配置的项目时,返回带有iframe的页面时,无法显示。
打开页面工具看到提示
Refused to display in a frame because it set 'X-Frame-Options' to 'DENY'
上网找了半天,都说明了问题,以及在WEB.xml或其它XML文件的配置方法
结合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内容无法显示,解决问题!
特此记录