*
lsh
2025-11-25 af2ebb4ebbcb69f6385947aa322a508464388494
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
package com.zy.common.config;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
/**
 * Created by vincent on 2019-06-13
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
 
    @Autowired
    private AdminInterceptor adminInterceptor;
 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminInterceptor)
                .addPathPatterns("/**")
                ;
    }
//                .excludePathPatterns("/rgv/**");
 
 
//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping("/**") // 对所有接口生效
//                .allowedOrigins("http://127.0.0.1:8080") // 关键:指定您的前地址
//                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 允许的请求方法
//                .allowedHeaders("*") // 允许所有请求头
//                .allowCredentials(true) // 若前端请求需要携带Cookie等认证信息,此项设为true
//                .maxAge(3600); // 预检请求的缓存时间(秒)
//    }
}