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测试时的传参:
备注:
如果除文件外都是 query 类型的参数的话,就不需要在除文件参数外的其他地方加任何注解,依旧按照老方法传递即可
@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();
}
本文转载自: https://blog.csdn.net/qq_41650131/article/details/127868354
版权归原作者 hello_syz 所有, 如有侵权,请联系我们删除。
版权归原作者 hello_syz 所有, 如有侵权,请联系我们删除。