Spring security

143 阅读1分钟
  • There is no PasswordEncoder mapped for the id "null"

public class WebSecurityConfig extends WebSecurityConfigurerAdapter 类中添加

@Bean
public static NoOpPasswordEncoder passwordEncoder() {
    return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}
  • 403 Forbidden Error with ajax GET request Spring configure(HttpSecurity http)方法中添加
 //禁用CSRF
http.csrf().disable();
  • 设置静态资源不拦截
@Override
public void configure(WebSecurity web) throws Exception {
    //解决静态资源被拦截的问题
    web.ignoring().antMatchers("/css/**","/fonts/**",
            "/img/**","/js/**","/locate/**","/plugins/**");
}