Spring boot X-Frame-Options 异常 a frame because it set 'X-Frame-Options' to 'deny'

a frame because it set ‘X-Frame-Options‘ to ‘deny‘

在spring security配置的位置添加

http.headers().frameOptions().disable();

    protected void configure(HttpSecurity http) throws Exception {
        http.headers().frameOptions().disable();
        http.authorizeRequests()
                .antMatchers("/login", "/logout", "/getVerifyCode", "/validateVerifyCode")
                .permitAll()
                .anyRequest().authenticated()

                .and()
                .formLogin()
                .loginPage("/login")
                .successForwardUrl("/success")
                .failureForwardUrl("/failure")

                .and()
                .logout()
                .logoutUrl("/logout")
                .invalidateHttpSession(true)

                .and()
                .csrf().disable();
    }

Spring boot X-Frame-Options 异常 a frame because it set 'X-Frame-Options' to 'deny'

原文地址:https://www.cnblogs.com/yangchongxing/p/12284022.html

时间: 2024-08-01 06:29:28

Spring boot X-Frame-Options 异常 a frame because it set 'X-Frame-Options' to 'deny'的相关文章

Spring Boot 整合 Apache Solr 异常:Expected mime type application/octet-stream but got text/html 的解决.

解决方法:Spring Data Solr 3.0 以上版本 将@SolrDocument(solrCoreName = "new_core")  中的solrCoreName 字段改为使用collection字段即可 下面是问题解决经过: 暑假期间在做一个高并发的电商平台,需要用到Apache Solr. Solr 版本是7.4 , Spring Boot 版本是 2.0.4 , Spring Data Solr 为 3.0.9 网上大部分的教程用的版本比较旧,在实体类使用的都是  

Spring Boot 处理异常返回json

spring boot 老版本处理异常  对于浏览器客户端,返回error数据 对于非浏览器返回json数据, 主要取决于你的请求head 是什么 但是当我们自定义了:  老版本无论请求什么都会返回json异常数据, @ControllerAdvice public class UserExceptionHandler { @ResponseBody @ExceptionHandler(UserNotFoundExits.class) public Map<String, Object> ha

Spring Boot 中关于自定义异常处理的套路!

在 Spring Boot 项目中 ,异常统一处理,可以使用 Spring 中 @ControllerAdvice 来统一处理,也可以自己来定义异常处理方案.Spring Boot 中,对异常的处理有一些默认的策略,我们分别来看. 默认情况下,Spring Boot 中的异常页面 是这样的: 我们从这个异常提示中,也能看出来,之所以用户看到这个页面,是因为开发者没有明确提供一个 /error 路径,如果开发者提供了 /error 路径 ,这个页面就不会展示出来,不过在 Spring Boot 中

Spring boot集中异常处理

集中异常处理 方式一:ExceptionHandle 定义自己的异常类型,根据不同类型做不同处理,比如我定义的MyException: public class MyException extends RuntimeException { public MyException(String msg) { super(msg); } } 然后通过MyExceptionHandle处理该异常,需要注意的是异常不能在filter中抛出,抛出也没法捕获 @RestControllerAdvice pub

Spring Boot 出现 in a frame because it set &#39;X-Frame-Options&#39; to &#39;DENY&#39;

在spring boot项目中出现不能加载iframe 页面报一个"Refused to display 'http://......' in a frame because it set 'X-Frame-Options' to 'DENY'. "错误 解决方式: 因spring Boot采取的java config,在配置spring security的位置添加: @Override protected void configure(HttpSecurity http) throw

Spring、Spring Boot、Spring Frame、Spring MVC的区别

Spring框架就像一个厂商,其下有很多产品,如Spring Boot.Spring Frame.Spring Cloud等等. Spring Boot用于快速.方便.简单的搭建一个Spring项目.之所以说它快速.方便.简单,是因为Spring Boot融合看来很多第三方库,提供了配置这些库及本身的一些简单的方式,从而进行了简化,避免了我们自己对包的导入和繁琐的XML文件配置.我们来看下官方文档. 我们可以看到Spring内嵌了一些serverse等容器,通过Spring Boot的配置,可以

Spring boot处理OPTIONS请求

一.现象从fetch说起,用fetch构造一个POST请求. 1 fetch('http://127.0.0.1:8000/api/login', { 2 method: "POST", 3 headers: ({ 4 'Content-Type': 'application/x-www-form-urlencoded' 5 }), 6 body: "name=" + name + "&password=" + pwd 7 }).then

启动spring boot 异常

再我搭建spring boot工程后,run application的时候抛出下面异常 Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class

记一次spring boot中MongoDB Prematurely reached end of stream的异常解决

在spring boot项目中使用了mongodb,当一段时间没有操作mongodb,下次操作mongodb时就会出现异常.异常如下: org.springframework.data.mongodb.UncategorizedMongoDbException: Prematurely reached end of stream; nested exception is com.mongodb.MongoSocketReadException: Prematurely reached end o