index:1 Refused to display 'http://localhost:8080/home' in a frame because it set 'X-Frame-Options'

通过spring security登陆后,跳转到嵌套页面,报错:

index:1 Refused to display 'http://localhost:8080/home' in a frame because it set 'X-Frame-Options' to 'deny'.

 

看到了这个

https://blog.csdn.net/a494567309/article/details/80348557

 

解决方法:

在继承自  WebSecurityConfigurerAdapter 的类中复写 configure 方法,在其中添加

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

如下:

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {

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

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章