|
@@ -3,6 +3,7 @@ package com.ym.mec.collectfee.config;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
@@ -11,21 +12,22 @@ import com.ym.mec.collectfee.interceptor.RequestInterceptor;
|
|
|
|
|
|
@Configuration
|
|
|
public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
- public void addInterceptors(InterceptorRegistry registry) {
|
|
|
+ public void addInterceptors(InterceptorRegistry registry) {
|
|
|
// addPathPatterns 用于添加拦截规则, 这里假设拦截 /url 后面的全部链接
|
|
|
- List<String> includePathPatterns = new ArrayList<String>();
|
|
|
- includePathPatterns.add("/**");
|
|
|
-
|
|
|
- // excludePathPatterns 用户排除拦截
|
|
|
- List<String> excludePathPatterns = new ArrayList<String>();
|
|
|
- excludePathPatterns.add("/login");
|
|
|
-
|
|
|
- registry.addInterceptor(getRequestInterceptor()).addPathPatterns(includePathPatterns).excludePathPatterns(excludePathPatterns);
|
|
|
- }
|
|
|
-
|
|
|
- public RequestInterceptor getRequestInterceptor(){
|
|
|
+ List<String> includePathPatterns = new ArrayList<String>();
|
|
|
+ includePathPatterns.add("/**");
|
|
|
+
|
|
|
+ // excludePathPatterns 用户排除拦截
|
|
|
+ List<String> excludePathPatterns = new ArrayList<String>();
|
|
|
+ excludePathPatterns.add("/login");
|
|
|
+
|
|
|
+ registry.addInterceptor(getRequestInterceptor()).addPathPatterns(includePathPatterns).excludePathPatterns(excludePathPatterns);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public RequestInterceptor getRequestInterceptor() {
|
|
|
return new RequestInterceptor();
|
|
|
}
|
|
|
}
|