spring boot项目,请求回来,响应头中X-Frame-Options被设置为DENY,如下图
这个会导致使用iframe模式上传图片或者iframe嵌套页面时,会报如下异常信息:
Refused to display in a frame because it set ‘X-Frame-Options’ to ‘DENY’
解决方案:扩展WebSecurityConfigurerAdapter类,增加如下代码
protected void configure(HttpSecurity http) throws Exception {
http.headers().frameOptions().disable();//防止X-Frame-Options
}