title: How to post a complex multipart form to a controller in java?
body: <pre><code>@RequestMapping(value = "sendEmail", method = RequestMethod.POST,consumes = "multipart/form-data",produces="application/json")
  @ResponseBody
  public MessageResponse&lt;MessageDetailVo&gt; sendEmail(@RequestParam(value="inputRequest") String inputRequest, @RequestParam(value="file") List&lt;MultipartFile&gt; files) ;
  </code></pre>
  
  <p>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.</p>
  
  <pre><code>List&lt;MultipartFile&gt; files = new ArrayList&lt;MultipartFile&gt;();
  String inputRequest=givenParameter;
  
      for (AttachmentDetailVo file : oldAttachmentsList) {
  
          MockMultipartFile firstFile = new MockMultipartFile("file",
                  file.getFileName(), "text/plain", file.getByteContent());
  
          files.add(firstFile);
      }
  
  
  
      /////////////////////list &lt;multipartfile created
  
      MultiValueMap&lt;String, Object&gt; x = new MultiValueMap&lt;String,Object&gt;();
      x.add("inputRequest", inputRequest);
      x.add("file", files.toString());
  </code></pre>
  
  <p>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 ?</p>