WebConfig.java
1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cn.com.glsx.neshield.config;
import cn.com.glsx.auth.interceptor.WebRequestAuthorizeInterceptor;
import cn.com.glsx.auth.interceptor.WebFunctionPermissionInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;
/**
* @author payu
*/
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Resource
private WebRequestAuthorizeInterceptor authInterceptor;
@Resource
private WebFunctionPermissionInterceptor permissionInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
//1.加入的顺序就是拦截器执行的顺序,
//2.按顺序执行所有拦截器的preHandle
//3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle
registry.addInterceptor(authInterceptor)
.addPathPatterns("/**")
.excludePathPatterns("/")
.excludePathPatterns("/login")
.excludePathPatterns("/captcha")
.excludePathPatterns("/actuator/**")
.excludePathPatterns("/auth/**")
.excludePathPatterns("/api/**");
registry.addInterceptor(permissionInterceptor).addPathPatterns("/**");
}
}