如何配置拦截器,仅通过注释(我不喜欢在.XML文件中注册拦截器,我不使用基于.XML的配置)?
注意:我在互联网上看到的例子是,当我尝试使用org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter**,时,它建议使用,我发现它被废弃了*
我正在SpringWebMVC-5上测试SpringBoot-2
发布于 2018-08-01 02:11:58
在org.springframework.web.servlet.config.annotation.WebMvcConfigurer中,您可以使用Spring5
@EnableWebMvc
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(....);
}
}https://stackoverflow.com/questions/51624009
复制相似问题