@RequestMapping(value = "sendEmail", method = RequestMethod.POST,consumes = "multipart/form-data",produces="application/json")
@ResponseBody
public MessageResponse<MessageDetailVo> sendEmail(@RequestParam(value="inputRequest") String inputRequest, @RequestParam(value="file") List<MultipartFile> files) ;
The above code is the signature of my controller that expects a string and a multipart file list as request params. Now I am trying to use something like below to form the post params and am not able to form the client code. Anyother solution is also appreciated.
List<MultipartFile> files = new ArrayList<MultipartFile>();
String inputRequest=givenParameter;
for (AttachmentDetailVo file : oldAttachmentsList) {
MockMultipartFile firstFile = new MockMultipartFile("file",
file.getFileName(), "text/plain", file.getByteContent());
files.add(firstFile);
}
/////////////////////list <multipartfile created
MultiValueMap<String, Object> x = new MultiValueMap<String,Object>();
x.add("inputRequest", inputRequest);
x.add("file", files.toString());
files is the multipart file list that I want to send along with the String inputRequest. How can I send the required params to my spring controller? What else I need to add and correct in my code to send the proper request to controller ?