SpringMVC过滤swagger的拦截

增加拦截器后发现swagger无法访问,是因为swagger的内置接口被拦截了

继承WebMvcConfigurationSupport类后重写addResourceHandlers方法

重写 addResourceHandlers 方法如下:

@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/templates/**")
                .addResourceLocations("classpath:/templates/");
        registry.addResourceHandler("swagger-ui.html").addResourceLocations(
                "classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/");
    }

You may also like...

发表评论

电子邮件地址不会被公开。 必填项已用*标注