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); // 预检请求的缓存时间(秒)
|
// }
|
}
|