I have a Spring MVC REST controller that accepts a multipart file, as follows:
@Consumes(MediaType.MULTIPART_FORM_DATA) @RequestMapping(value = "/save-comment", method = RequestMethod.POST) public String addComment(@FormDataParam("jsonData") String jsonData, @FormDataParam("file") MultipartFile file, ModelMap model) { //My Logic to save file and data } I use Jersey REST client in my application. The above code works fine for me. Now I am trying to POST multiple files to my REST controller.
I tried to change @FormDataParam("file") MultipartFile file to @FormDataParam("file") MultipartFile[] file but it is not working for me. How can I pass multiple files at a time to a REST controller?
The exception I get is: nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate [[Lorg.springframework.web.multipart.MultipartFile;]: No default constructor found; nested exception is java.lang.NoSuchMethodException: [Lorg.springframework.web.multipart.MultipartFile;.<init>()] with root cause java.lang.NoSuchMethodException: [Lorg.springframework.web.multipart.MultipartFile;.<init>()