springBoot静态资源路径映射配置不生效,浏览器访问为404
因为Spring MVC 处理程序映射匹配请求路径的默认策略已从 AntPathMatcher 更改为PathPatternParser。
所以在配置文件中也配置了spring.mvc.pathmatch.matching-strategy=ant-path-matcher,但还是没有任何效果
@Slf4j
@Configuration
public class templateWebMvcConfig implements WebMvcConfigurer{
private static String localhostPath = "file:/Users/zhuyuanyang/Desktop/test/javaimg/";
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
log.info("开始解析地址");
registry.addResourceHandler("/images/**").
addResourceLocations(localhostPath);
log.info("结束解析地址");
}
}