@Configuration
public class MyFilterConfig {
@Bean(name="sysVisitFilter")
public SysVisitFilter sysVisitFilter(){
return new SysVisitFilter();
}
@Bean
public FilterRegistrationBean sysVisitFilterBean() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(new DelegatingFilterProxy("sysVisitFilter"));
registrationBean.addInitParameter("targetFilterLifecycle","true");
registrationBean.addUrlPatterns("/*");
registrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico");
registrationBean.setDispatcherTypes(DispatcherType.REQUEST);
// 一定要设置false 否则过滤器执行两次
registrationBean.setEnabled(false);
return registrationBean;
}
}