pom.xml里添加依赖
<dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>5.2.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>5.2.1.RELEASE</version> </dependency>
添加或去掉x-frame-options deny安全头
package com.chinasofti.cloudeasy.config; import 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 WebSecurityConfiguration extends WebSecurityConfigurerAdapter { // @Override // protected void configure(AuthenticationManagerBuilder auth) throws Exception { // auth.inMemoryAuthentication().withUser("a").password("a").roles("USER"); // } @Override protected void configure(HttpSecurity http) throws Exception { http.headers().frameOptions().sameOrigin(); // 同源跨域 http.headers().frameOptions().deny(); http.headers().frameOptions().disable(); } }