Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

spring的内置filter/interceptor和自定义的filter、interceptor先后顺序怎样?

spring的内置filter和springmvc内置interceptor和自定义的没有指定order的filter、interceptor先后顺序怎样?
自定义的在内置的之前还是之后执行?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

按照我的理解,filter是有顺序的,比如在web.xml中的配置的顺序,或者spring boot主动注册的顺序:

FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setOrder(6);
        filterRegistrationBean.setFilter(new XXXFilter());
        filterRegistrationBean.setName("filter1");
        filterRegistrationBean.addUrlPatterns("/*");
        return filterRegistrationBean;

这些都是有顺序的,按照的你问题来说,既然没顺序,那肯定不是web.xml(这种只要配置就会有顺序),那我就任务你是spring boot,我没有尝试过使用filter却没设置order,不过你可以参考我的一篇文章尝试自己debug一下,看看是什么顺序,https://ostack.cn/a/11...
也可以继续等高手回复


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...