首页新闻找找看学习计划

FormData向后台传文件,后台接收不到报错

0
悬赏园豆:20 [待解决问题]

formdata数据:
------WebKitFormBoundaryHw8awRPuYAW8ZCUB
Content-Disposition: form-data; name="files"; filename="Martin Garrix.jpg"
Content-Type: image/jpeg

------WebKitFormBoundaryHw8awRPuYAW8ZCUB
Content-Disposition: form-data; name="files"; filename="Martin Garrix.jpg"
Content-Type: image/jpeg

------WebKitFormBoundaryHw8awRPuYAW8ZCUB
Content-Disposition: form-data; name="goods"

{"goodsName":"wwqe","goodsDescribe":"wqe","categoryId":"608834794213605376","goodsStock":"123","goodsPrice":"23","goodsStatus":"1"}
------WebKitFormBoundaryHw8awRPuYAW8ZCUB--

报错:
error: "Unsupported Media Type"
message: "Content type 'application/octet-stream' not supported"
path: "/goods"
status: 415
timestamp: "2019-08-07T19:12:05.631+0000"
trace: "org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported

Controller方法:
@PostMapping(value = "")
@ResponseBody
public Result<PageModel> insert(@RequestPart("goods") Goods goods, @RequestParam("files") MultipartFile[] files) {
logger.info("添加商品");

    return Result.success("sad", null);

}
我看网上都是这么写的,为什么我的报错了,有大佬能解惑吗

Azkrale的主页 Azkrale | 初学一级 | 园豆:182
提问于:2019-08-08 03:17
< >
分享
所有回答(1)
0

把@ResponseBody注解删掉估计可以

不若为止 | 园豆:225 (菜鸟二级) | 2019-08-09 17:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册