1.登录怎么都不进入security里面的方法,而是请求后,自动转到登录页面。
调试发现 重写了 configure的方法,但是里面代码是空导致,整个方法删掉就好了。
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception{
}
2.自定义过滤器,虽然公用一个也可以,不过分开更好。
参考:https://blog.csdn.net/biboheart/article/details/80666700
修改SecurityConfiguration
package com.truelore.nbzlcy.security;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.mapping.GrantedAuthoritie