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();
    }

}

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