SpringBoot2 Filter执行两次问题解决
作者:互联网
@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;
}
}
标签:registrationBean,false,FilterRegistrationBean,两次,Filter,SpringBoot2,addInitParam 来源: https://www.cnblogs.com/coderdxj/p/11445303.html