gpt4 book ai didi

java - spring security第一次登录失败,第二次登录成功

转载 作者:行者123 更新时间:2023-11-29 04:36:40 24 4
gpt4 key购买 nike

我有一个问题,当我第一次登录时我会得到

{"timestamp":1481719982036,"status":999,"error":"None","message":"No message available"} 但第二个没问题。如果我清除缓存。我也失败了.这是主要代码:

@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Autowired
private DataSource dataSource;

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(dataSource)
.usersByUsernameQuery("select username,password,TRUE from authority where username = ?")
.authoritiesByUsernameQuery("select username,role from authority where username = ?")
.passwordEncoder(passwordEncoder());

}

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/login/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login").permitAll()
.loginProcessingUrl("/login/check").permitAll()
.defaultSuccessUrl("/index").failureUrl("/login?failed=true")
.permitAll()
.and()
.logout().logoutSuccessUrl("/login").logoutUrl("/login?logout")
.and().csrf().disable();
}

@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/static/**", "/js/**", "/css/**", "/img/**", "/json/**");
}

@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}

}

我不知道发生了什么。

最佳答案

检查您是否拥有以下所有文件夹

"/static/**", "/js/**", "/css/**", "/img/**", "/json/**"

异常

{"timestamp":1481719982036,"status":999,"error":"None","message":"No message available"}

当文件夹不存在但被排除时抛出。

关于java - spring security第一次登录失败,第二次登录成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41144028/

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