gpt4 book ai didi

java - Spring安全不允许资源,登录后浏览器只显示一个css文件?

转载 作者:行者123 更新时间:2023-12-02 10:09:10 27 4
gpt4 key购买 nike

@Override
protected void configure(HttpSecurity httpSecurity) throws Exception{
httpSecurity
.authorizeRequests()
.antMatchers("/resources").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/myList")
.permitAll()
.and()
.logout()
.permitAll();
}

我尝试为 Spring 安全性创建一个自定义登录页面,但经过几个小时后仍然遇到同样的问题。整个项目是用java和HTML/CSS制作的。谢谢您的帮助!

最佳答案

要忽略资源,您应该使用 WebSecurity 而不是 HttpSecurity

@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/resources/**");
}

更多解释请参见this question

关于java - Spring安全不允许资源,登录后浏览器只显示一个css文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55116843/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com