MVC Java配置-HandlerInterceptor不排除路径
我有一个MVC Java配置,但是HandlerInterceptor不排除某些模式。
在标有 的行上,如果
1)我同时添加addPatterns("/**")和excludePathPatterns("*.ecxld")对HandlerInterceptor的InterceptorRegistration时,HandlerInterceptor.preHanlde()是不是在所有调用。例如.addPathPatterns("/**").excludePathPatterns("*.ecxld")
2)我只添加excludePathPatterns("*.ecxld")到HandlerInterceptor的InterceptorRegistration,则HandlerInterceptor.preHanlde()仍执行。
(其他拦截器调用正常)。
任何指针表示赞赏。
谢谢
@Configurationpublic class MyMVCConfigurerAdapter extends WebMvcConfigurerAdapter {
@Override
public void addInterceptors(final InterceptorRegistry registry) {
registry.addInterceptor(getInterceptorOne());
registry.addInterceptor(getMyHandlerInterceptor())
.excludePathPatterns("*.ecxld"); // **xxx**
registry.addInterceptor(getInterceptorTwo()
);
}
回答:
调试后,拦截器不会按照添加顺序执行。在上面的示例中,先执行interceptorOne,然后是interceptorTwo,然后执行处理程序(具有排除的模式)。
以上是 MVC Java配置-HandlerInterceptor不排除路径 的全部内容, 来源链接: utcz.com/qa/420955.html
