SpringBoot "x-frame-options" to "deny"
背景:
今天项目中用到iframe嵌入网页, 浏览器报错 in a frame because it set 'X-Frame-Options' to 'deny'
原因:
SpringSecurty使用X-Frame-Options防止网页被Frame
解决:
把x-frame-options 设置为disable即可
代码: headers().frameOptions().disable()
如下:
protected void configure(HttpSecurity http) throws Exception {
//防止iframe
http.headers().frameOptions().disable();
}
补充说明:X-Frame-Options 三个值的意思:(主要:网上找的图)