跨域
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter{
@Autowired
private AuthInterceptor authInterceptor;
@Autowired
private UserParameterResolver userParameterResolver;
@Override
public void addInterceptors(InterceptorRegistry registry) {
//registry.addInterceptor(authInterceptor).addPathPatterns("/**");
super.addInterceptors(registry);
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(userParameterResolver);
super.addArgumentResolvers(argumentResolvers);
}
// 增加這句
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*");
}
}
配置靜態(tài)文件訪問
spring:
mvc:
date-format: ${custom.common-date-format}
static-path-pattern: "/**"