@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);
})