默认情况下,Spring Security是禁用iframe内呈现的,即: X-Frame-Options: DENY
开启同一个域的使用,可以在head中添加如下代码: <frame-options policy="SAMEORIGIN" />
在后台java中配置,如下所示:1
2
3
4
5
6
7
8
9
10
11
12
13import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity
public class WbUserSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.headers().frameOptions().sameOrigin();
}
}
需要随意的使用,则可以使用语句
http.headers().frameOptions().disable()来禁用该功能;