All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.net.wanmo.ocr.config.WebMvcConfig Maven / Gradle / Ivy

package cn.net.wanmo.ocr.config;

import cn.net.wanmo.ocr.interceptor.SignInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * WebMvc配置
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
    @Resource
    private SignInterceptor signInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //不拦截的地址
        List excludedList = new ArrayList<>();
        //swagger地址
        excludedList.add("/swagger-ui.html");
        excludedList.add("/swagger-ui.html/**");
        excludedList.add("/webjars/**");
        excludedList.add("/swagger/**");
        excludedList.add("/doc.html");
        excludedList.add("/doc.html/**");
        excludedList.add("/swagger-resources/**");
        excludedList.add("/v2/**");
        excludedList.add("/favicon.ico");
        //生成应用id和密钥接口不拦截
        excludedList.add("/getSecret");
        //测试地址不拦截
        excludedList.add("/hello/**");


        registry.addInterceptor(signInterceptor)
                .addPathPatterns("/**")//拦截所有请求
                .excludePathPatterns(excludedList);//排除的请求
        super.addInterceptors(registry);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy