MyHandlerInterceptor没有在spring容器的管理中,yml文件中配置的过滤条件加载不了。
在MyHandlerInterceptor中:
private List<String> noSessionUriList;
private List<String> noSessionSuffixList;
private String rootUri;
在MyWebConfigurer中将配置文件中的配置加载到MyHandlerInterceptor中:
@Configuration
public class MyWebConfigurer extends WebMvcConfigurerAdapter {
@Autowired
private Config config;
@Override
public void addInterceptors(InterceptorRegistry registry) {
MyHandlerInterceptor interceptor = new MyHandlerInterceptor();
interceptor.setNoSessionUriList(Arrays.asList(config.getNoSessionUri().split(",")));
interceptor.setNoSessionSuffixList(Arrays.asList(config.getNoSessionSuffix().split(",")));
interceptor.setRootUri(config.getRootUri());
registry.addInterceptor(interceptor)
.addPathPatterns("/**");
super.addInterceptors(registry);
}
}