package com.jeesite.modules.config; import com.jeesite.common.config.Global; import com.jeesite.common.lang.StringUtils; import com.jeesite.modules.interceptor.MesClientAccessLogInterceptor; import com.jeesite.modules.interceptor.SiteClosedInterceptor; import com.jeesite.modules.sys.log.LogJsonResultSupport; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class WebConfig implements WebMvcConfigurer { @Autowired private SiteClosedInterceptor siteClosedInterceptor; @Autowired private LogJsonResultSupport logJsonResultSupport; @Autowired private MesClientAccessLogInterceptor mesClientAccessLogInterceptor; @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(siteClosedInterceptor); registry.addInterceptor(logJsonResultSupport).addPathPatterns("/**/sys/log/form"); applyLogPaths(registry.addInterceptor(mesClientAccessLogInterceptor)); } private void applyLogPaths(InterceptorRegistration registration) { String add = Global.getProperty("web.interceptor.log.addPathPatterns"); String exclude = Global.getProperty("web.interceptor.log.excludePathPatterns"); if (StringUtils.isBlank(add)) { registration.addPathPatterns("/a/**"); } else { for (String p : StringUtils.split(add, ",")) { if (StringUtils.isNotBlank(p)) { registration.addPathPatterns(p.trim()); } } } if (StringUtils.isNotBlank(exclude)) { for (String p : StringUtils.split(exclude, ",")) { if (StringUtils.isNotBlank(p)) { registration.excludePathPatterns(p.trim()); } } } } }