ITPub博客

首页 > 应用开发 > > 帮我哥们解答下,FormData向后台传文件,后台接收不到报错

帮我哥们解答下,FormData向后台传文件,后台接收不到报错

作者:petterchx 时间:2019-08-09 15:36:35 0 删除 编辑

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 insert(@RequestPart("goods") Goods goods, @RequestParam("files") MultipartFile[] files) {

logger.info("添加商品");

returnResult.success("sad",null);

}

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

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4606/viewspace-3134211/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-10-24

  • 博文量
    131
  • 访问量
    30132