这是我的方法
@RequestMapping(value = "/test", method = RequestMethod.POST)
public String test(@RequestParam(value = "preset[]") String[] preset,
@RequestParam(value = "file") MultipartFile file)
这是JQuery代码
formData = new FormData();
formData.append("file", $('#file-id').prop('files')[0]);
formData.append('preset[]', JSON.stringify(["date", "time"]));
$.ajax({
method: "POST",
data: formData,
url: '/test',
enctype: 'multipart/form-data',
processData: false,
contentType: false,
cache: false,
success: (res) => {
console.log(res)
},
error: (err) => {
console.log(err);
}
})
嗯,它不起作用。服务器无法解析数组。我在做什么错了?