package com.newfiber.config; import com.newfiber.common.interceptor.JurInterceptor; import com.newfiber.common.interceptor.LoginInterceptor; import javax.annotation.Resource; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; /** * MVC配置 * @author hy */ @Configuration public class WebMvcConfig extends WebMvcConfigurerAdapter { /** 登录请求拦截器 */ @Resource private LoginInterceptor loginInterceptor; /** 权限验证拦截器 */ @Resource private JurInterceptor jurInterceptor; @Override public void addInterceptors(InterceptorRegistry registry) { registry .addInterceptor(loginInterceptor) .addPathPatterns("/**") .excludePathPatterns("/logininfo/login", "/logininfo/logout", "/pumpInfo/queryAllSanwei", "/pumpInfo/operationSanwei", "/users/getProjectUser", "/users/getNoProjectUser", "/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**", "/doc.html/**", "/rest_template/**", "/equinfo/export_excel_template", "/file/save"); registry .addInterceptor(jurInterceptor) .addPathPatterns("/**") .excludePathPatterns("/logininfo/login", "/logininfo/logout", "/pumpInfo/queryAllSanwei", "/pumpInfo/operationSanwei", "/users/getProjectUser", "/users/getNoProjectUser", "/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**", "/doc.html/**", "/rest_template/**", "/equinfo/export_excel_template", "/file/save"); super.addInterceptors(registry); } /** * 配置静态访问资源 * @param registry */ @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); registry.addResourceHandler("swagger-ui.html","doc.html") .addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**") .addResourceLocations("classpath:/META-INF/resources/webjars/"); super.addResourceHandlers(registry); } }