赞
踩
使用springboot配置映射静态资源目录后,英文和数字可以正常进行访问,但是中文就提示404
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/file/video/**").addResourceLocations(props.getVideoFolder());
}
原文传送门,有分析过程
@Configuration public class WebConfig implements WebMvcConfigurer { @Override public void configurePathMatch(PathMatchConfigurer configurer) { UrlPathHelper urlPathHelper=new UrlPathHelper(); urlPathHelper.setUrlDecode(false); urlPathHelper.setDefaultEncoding(StandardCharsets.UTF_8.name()); configurer.setUrlPathHelper(urlPathHelper); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/files/**").addResourceLocations("file:E:/FileUpload/HmiInterface/"); } }
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
版本问题,最为致命
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。