mvc传参数?

@PutMapping("/post")
@ResponseBody
public PicUploadResult uploadpost(@RequestParam("postImage") MultipartFile postImg,Post post) {
    System.out.println(post);
    return this.picUploadService.uploadpost(postImg,post);
}

如图中在写逻辑层时需要传入两个参数,一个是文件类型,另外一个是对象。
应该如何怎么来写 @RequestParam@RequestBody

var a1 = {'userId':this.user.userId};
var a2 = {'postTime':aData};
var a3 = {'topic':form.topic};
var a4 = {'content':form.content};
var a5 = {'image':form.image};
this.newpost = Object.assign(a1, a2, a3, a4, a5);
console.log(this.newpost);
let param = new FormData()
param.append('postImage', this.file)
console.log(param)
axios
    .post("http://localhost:8080/pic/upload/post", param, this.newpost)
    .then(function(response) {
        console.log(response.data);
    })
阅读 1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进