需要:同时需要上传文件和JSON对象属性
方式一:
使用注解@RequestParam("file" MultipartFile file)和@RequestParam("name") String name ...)
将JSON对象的属性逐个使用@RequestParam传入可以实现
但是这样列出了,用惯了传JSON对象,有点繁琐。
方式二:
使用注解@RequestParam("file" MultipartFile file)和@RequestPart("json") Object json)
在使用传入JSON对象使用需要指明Content-type为 application/json
如下图: