Java 访问控制允许原点';响应中的头不能是通配符'*';
我有Spring启动应用程序。我还使用SpringSecurity和Thymeleaf\ 我有一段代码,可以从数据库中获取tube视频,并将其应用到我的thymeleaf模板中。 如果我在浏览器(任何)中打开开发工具,我会收到错误消息: 访问位于的XMLHttpRequest "来源" “”已被CORS策略阻止:值为 响应中“Access Control Allow Origin”标头的 当请求的凭据模式为“包含”时,必须使用通配符“*”。 XMLHttpRequest启动的请求的凭据模式为 由withCredentials属性控制 如果我删除一段代码与你管视频错误将消失 如何解决此错误? Spring安全配置:Java 访问控制允许原点';响应中的头不能是通配符'*';,java,spring-boot,spring-security,thymeleaf,Java,Spring Boot,Spring Security,Thymeleaf,我有Spring启动应用程序。我还使用SpringSecurity和Thymeleaf\ 我有一段代码,可以从数据库中获取tube视频,并将其应用到我的thymeleaf模板中。 如果我在浏览器(任何)中打开开发工具,我会收到错误消息: 访问位于的XMLHttpRequest "来源" “”已被CORS策略阻止:值为 响应中“Access Control Allow Origin”标头的 当请求的凭据模式为“包含”时,必须使用通配符“*”。 XMLHttpRequest启动的请求的凭据模式为 由
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/admin/**").authenticated()
.antMatchers("/**").permitAll()
.and().exceptionHandling().accessDeniedPage("/handlers/access-denied.html")
.and().csrf().disable();
}
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers(
// статика
"/css/**",
"/js/**",
"/fonts/**",
"../libs/**",
"/images/**"
);
}
}
模板: