#出现这个问题的原因是因为Spring Security默认将header response里的X-Frame-Options属性设置为DENY。
如果页面里有需要通过iframe/frame引用的页面,需要配置Spring Security允许iframe frame加载同源的资源,方法为在Spring Security的配置类里将header response的X-Frame-Options属性设置为SAMEORIGIN,具体可以参考如下代码:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/res/**", "/admin", "/thirdparty/**", "/auth/login").permitAll()
.antMatchers("/admin/**").hasAuthority("admin:index")
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/admin").permitAll()
.and()
.logout().logoutUrl("/admin/logout").logoutSuccessUrl("/admin").invalidateHttpSession(true)
.and()
.csrf().disable()
.headers().frameOptions().sameOrigin();
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)