content: package com.xxl.job.admin.config;
  
  import org.springframework.context.annotation.Configuration;
  import org.springframework.stereotype.Component;
  import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  
  import com.xxl.job.admin.controller.interceptor.PermissionInterceptor;
  
  @Configuration
  public class MyWebMvcConfigurer extends WebMvcConfigurerAdapter {
      @Override
      public void addInterceptors(InterceptorRegistry registry) {
          registry.addInterceptor(new PermissionInterceptor()).addPathPatterns("/**").excludePathPatterns("/toLogin");
          super.addInterceptors(registry);
  
      }
  
      /**
       * 过去要访问一个页面需要先创建个Controller控制类，再写方法跳转到页面
       * 在这里配置后就不需要那么麻烦了，直接访问http://localhost:8080/toLogin就跳转到login.jsp页面了
       *
       * @param registry
       */
      @Override
      public void addViewControllers(ViewControllerRegistry registry) {
          registry.addViewController("/").setViewName("/toLogin");
          super.addViewControllers(registry);
      }
  
  }
  