您可以尝试以下操作:
创建
Blob
使用JSON数据(requestData):
var requestData = JSON.stringify(nokInfoDatas);
var fd = new FormData();
fd.append('photo', file);
fd.append('testId', testId);
fd.append('nokDataList', new Blob([requestData], {
type: "application/json"
}));
将@RequestParam更改为
@RequestPart
用于使用多部分解析JSON。
public @ResponseBody String answer(HttpServletRequest request,
@RequestParam(value = "photo") MultipartFile photo,
@RequestParam(value = "testId") String testId,
@RequestPart(value = "nokDataList") List<NokDataDTO> nokInfoDtos
)