controller层接收参数 文件+对象时报的错
@PostMapping("/toUpdateArticle1")
@ApiOperation("修改文章1")
public ResultResponse<Integer> updateArticle1(@RequestParam(value = "imgShow",required = false) MultipartFile imgShow,@RequestBody UpdateArticleVO updateArticleVO){
return process(()->articleService.updateArticle(updateArticleVO,imgShow));
}
解决方法: 1.把对象改为string 然后通过string转换成对象
@PostMapping("/toUpdateArticle")
@ApiOperation("修改文章")
public ResultResponse<Integer> updateArticle(@RequestParam(value = "imgShow",required = false) MultipartFile imgShow,@RequestParam("updateArticleVOStr") String updateArticleVOStr){
try {
//将saveArticleVOStr转换成saveArticleVO
UpdateArticleVO updateArticleVO= JSONObject.parseObject(updateArticleVOStr,UpdateArticleVO.class);
//业务逻辑
return process(()->articleService.updateArticle(updateArticleVO,imgShow));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
2.第二种方法 也没啥好讲的 那就是分开来写接口