1,Java后端代码:(注意 @RequestPart 注解的使用哦!)
@ApiOperation(value = "信息发布", notes = "信息发布", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "informationPublicationReleaseParam", value = "JSON串名", dataType = "MultipartFile"),
@ApiImplicitParam(name = "multipartFile", value = "文件名", dataType = "List<Integer>"),
})
@PostMapping(value = "/release")
public Result release(@RequestPart("informationPublicationReleaseParam") InformationPublicationReleaseParam informationPublicationReleaseParam, @RequestPart("multipartFile") List<MultipartFile> multipartFiles) {
informationPublicationService.release(informationPublicationReleaseParam, multipartFiles);
return Result.success();
}
2,Postman测试时的传参:
备注:文章来源:https://www.toymoban.com/news/detail-536101.html
如果除文件外都是 query 类型的参数的话,就不需要在除文件参数外的其他地方加任何注解,依旧按照老方法传递即可文章来源地址https://www.toymoban.com/news/detail-536101.html
@ApiOperation(value = "信息发布", notes = "信息发布", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "informationPublicationReleaseParam", value = "JSON串名", dataType = "MultipartFile"),
@ApiImplicitParam(name = "multipartFile", value = "文件名", dataType = "List<Integer>"),
})
@PostMapping(value = "/release")
public Result release(InformationPublicationReleaseParam informationPublicationReleaseParam, @RequestPart("multipartFile") List<MultipartFile> multipartFiles) {
informationPublicationService.release(informationPublicationReleaseParam, multipartFiles);
return Result.success();
}
到了这里,关于传json的同时传递多个MultipartFile的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!