I have the following controller method for uploading multiple files at once, inspired by this blog post and answers to this question as well:
@RequestMapping(value = "/{user}/attachment", method = RequestMethod.POST)
@PreAuthorize(...)
public void upload(@PathVariable User user,
@RequestParam("file") List<MultipartFile> files) {
// handle files
}
However, the list of the files is always empty although request contains them.
If I add the third MultipartRequest
parameter to the method:
public void upload(@PathVariable User user,
@RequestParam("file") List<MultipartFile> files,
MultipartRequest request)
I can see it contains my uploaded files correctly:
What might be the reason of empty List<MultipartFile>
?
I'm using ng-file-upload to submit the files, but I don't think it is connected with the issue. Spring 4.2.4.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…