美文网首页
Spring Boot解决“in a frame because

Spring Boot解决“in a frame because

作者: 口袋妖怪哆啦A梦 | 来源:发表于2018-08-26 00:05 被阅读0次

    当你尝试在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

    相关文章

      网友评论

          本文标题:Spring Boot解决“in a frame because

          本文链接:https://www.haomeiwen.com/subject/bbeniftx.html