出现的问题:
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=----WebKitFormBoundaryIBTZ4p7VXFBcieRt;charset=UTF-8' not supported
如果一个实体类中同时包括文件和文本类型,如:
public class entity {
private MultipartFile inputFile1;
private Integer number;
private String text;
}
这时候前端给我传的内容要放在form-data中,后端在进行接受的时候也不能使用@RequestBody来接受,因为@RequstBost接受的类型为application/json,而form-data的接受类型是application/x-www-form-urlencoded。
方案:
后端接口接受参数直接用实体类接受,去掉@RequestBody,解决