InterceptorConfig.java 918 B

1234567891011121314151617181920212223242526272829
  1. package com.fdage.config;
  2. import com.fdage.listner.LoggerInterceptor;
  3. import org.springframework.context.annotation.Bean;
  4. import org.springframework.context.annotation.Configuration;
  5. import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  6. import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  7. /**
  8. * Created by Hb_zzZ on 2018/12/6.
  9. */
  10. @Configuration
  11. public class InterceptorConfig extends WebMvcConfigurerAdapter {
  12. @Bean
  13. public LoggerInterceptor loggerInterceptor(){
  14. return new LoggerInterceptor();
  15. }
  16. @Override
  17. public void addInterceptors(InterceptorRegistry registry) {
  18. //这里可以添加多个拦截器
  19. registry.addInterceptor(loggerInterceptor()).addPathPatterns("/**")
  20. .excludePathPatterns("/","","/error","/login","/register","/resetPassword");
  21. super.addInterceptors(registry);
  22. }
  23. }