配置 LoginInterceptorcss
@Service
public class LoginInterceptor implements Filter {ide
@Override public void init(FilterConfig filterConfig) throws ServletException { System.out.println("init"); } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { chain.doFilter(httpServletRequest,httpServletResponse); } @Override public void destroy() { System.out.println("完成了"); }
在 SecurityConfig裏面配置ui
@Autowired
private LoginInterceptor myFilterSecurityInterceptor;
@Override.net
protected void configure(HttpSecurity http) throws Exception { http .formLogin().loginPage("/authentication/require") .loginProcessingUrl("/authentication/form") .successHandler(myLoginAuthSuccessHandler).and() .authorizeRequests().antMatchers("/authentication/require", "/authentication/form", "/**/*.js", "/**/*.css", "/**/*.jpg", "/**/*.png", "/**/*.woff2", "/auth/*", "/oauth/*", "/login/**", "/mylogout", "/exit" ) .permitAll() .anyRequest().authenticated().and().anonymous().disable().exceptionHandling().authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/login?error")).and() .csrf().disable(); http.addFilterBefore(myFilterSecurityInterceptor, FilterSecurityInterceptor.class); }
做者:雲大牛1994
來源:CSDN
原文:https://blog.csdn.net/qq_4359...
版權聲明:本文爲博主原創文章,轉載請附上博文連接!code