Spring Boot解決“in a frame because it set 'X-Frame-Options' to 'deny'.”

當你嘗試在Spring Boot項目中使用iframe標簽時,瀏覽器會報“in a frame because it set 'X-Frame-Options' to 'deny'.”的錯誤。解決辦法如下:

@EnableWebSecurity
public class WebSecurityConfig extends
        WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            // ...
            .headers()
                .frameOptions().sameOrigin()
                .httpStrictTransportSecurity().disable();
    }
}

參考https://docs.spring.io/spring-security/site/docs/current/reference/html/headers.html

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,568評論 19 139
  • Spring Boot 參考指南 介紹 轉(zhuǎn)載自:https://www.gitbook.com/book/qbgb...
    毛宇鵬閱讀 47,273評論 6 342
  • 原文鏈接:https://docs.spring.io/spring-boot/docs/1.4.x/refere...
    pseudo_niaonao閱讀 4,895評論 0 9
  • =========================================================...
    _燈火闌珊處閱讀 2,544評論 0 3
  • 感謝堂妹挺著大肚子,專門跑來給我送櫻桃 忽然覺得: 在外漂泊久了, 回“家”的感覺真好 少年離家 中年歸 鄉(xiāng)音無...
    秦悠然閱讀 364評論 0 1

友情鏈接更多精彩內(nèi)容