MvcConfig.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. package com.yihu.iot.config;
  2. import com.yihu.iot.interceptor.GateWayInterceptor;
  3. import org.slf4j.Logger;
  4. import org.slf4j.LoggerFactory;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.context.annotation.Configuration;
  7. import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  8. import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  9. /**
  10. * Created by chenweida on 2017/4/6.
  11. */
  12. @Configuration
  13. public class MvcConfig extends WebMvcConfigurerAdapter {
  14. private Logger logger = LoggerFactory.getLogger(MvcConfig.class);
  15. @Autowired
  16. private GateWayInterceptor gateWayInterceptor;
  17. @Override
  18. public void addInterceptors(InterceptorRegistry registry) {
  19. // 多个拦截器组成一个拦截器链
  20. // addPathPatterns 用于添加拦截规则
  21. // excludePathPatterns 用户排除拦截 ,/third/juye/kit/**
  22. registry.addInterceptor(gateWayInterceptor).addPathPatterns("/svr-iot/open/gc/**").excludePathPatterns(
  23. "/svr-iot/open/gc/accesstoken",
  24. "/svr-iot/open/gc/createGcClientDetails");
  25. super.addInterceptors(registry);
  26. logger.info("init gateWayInterceptor");
  27. }
  28. }