标签:ring cti dep style multi 微信小程序 ons postman multipart
项目:spring boot + mybatis plus + spring + redis
测试接口
@ApiOperation(value = "单文件上传测试接口") @PostMapping(value = "/file") public String fileUpload(MultipartFile file) { if (file.getSize() > 0) { System.out.println("上传成功"); } return ""; }
swagger或postman测试发现,file参数接收不到文件,始终为null。
解决方案:
<!-- <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>1.3.2</version> </dependency>--> <!-- <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.2</version> </dependency>-->
/*@Configuration public class MultipartResolverConfig { @Bean(name = "multipartResolver") public MultipartResolver multipartResolver(){ CommonsMultipartResolver resolver = new CommonsMultipartResolver(); //上传文件大小 10M 10*1024*1024 resolver.setMaxUploadSize(10*1024*1024); resolver.setDefaultEncoding("UTF-8"); return resolver; } }*/
结束
标签:ring cti dep style multi 微信小程序 ons postman multipart
原文地址:https://www.cnblogs.com/it-deepinmind/p/12717503.html