我想在DB中保存一个实体。实体有几个字段和照片(我将保存在byte[]中的照片)。我写了一个RestController,但没有用。格式化JSON,我使用postman,在form-data中我添加了一个文件,在raw中我使用了body并使用了JSON。
@RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = {"multipart/form-data"})
@ResponseBody
public void storeAd(@RequestPart("client") @Valid Client client, @RequestPart("file") @Valid MultipartFile file) throws IOException {
Client myClient = client;
byte[] s = file.getBytes();
int a = s.length;
}我看到错误:由处理程序执行引起的已解决的异常:
org.springframework.web.HttpMediaTypeNotSupportedException:
Content type 'application/json' not supported邮递员1的请求
发布于 2018-11-29 10:35:12
您需要在标题部分中添加“Content:application/x form-urlencoded”。
https://stackoverflow.com/questions/53536579
复制相似问题