title: How to get the multipart file from jquery to spring controller
body: <p>I am using the spring mvc form,jquery to submit the form.Along with all the form values there is multipart file upload.</p>
  
  <p>Following is the UI code,</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="form-group"&gt;
       &lt;span class="fileinput-new"&gt;Select file&lt;/span&gt; &lt;span class="fileinput-exists"&gt;Change&lt;/span&gt; 
       &lt;form:input type="file" id="addrDocImage" path="addrDocImage" name="addrDocImage"/&gt;
      &lt;/span&gt; 
      &lt;/div&gt;
   </code></pre>
  </div>
  </div>
  </p>
  
  <p>here is my java script code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>   $.ajax({
              url: form.action,
              type: form.method,
              data: $(form).serialize(),
              beforeSend: function(xhr){
               xhr.setRequestHeader('X-CSRF-Token', $("meta[name='_csrf']").attr("content"));
           },
              success: function(response) {
               $('#merchantAddressCreationForm').modal('hide');
               //$('#merchantAddressCreationForm').modal('toggle');
            swal({
                   title: "",
                   text: response,
               }, function() {
                  $.ajax({
              type: 'GET',
              url: 'addressDetails',
              data : "_csrf="+$("meta[name='_csrf']").attr("content"),
              success:function(data){
               $(".merchant_address_data").html(data);
              },
              error:function(response){
              }
             });
         }); 
              }            
          });
      }
  }); </code></pre>
  </div>
  </div>
  </p>
  
  <p>And my dto with multipart is  </p>
  
  <pre><code> public class AddressDTO implements Serializable {
  
  private static final long serialVersionUID = 2931368070275666084L;
  private long addrId;
  private long partyId;
  private String locationName;
  private MultipartFile addrDocImage;
       ''''''
  }
  </code></pre>
  
  <p>But I am getting the addrDocImage as null when I am submitting the form.</p>
  
  <p>Following is the controller method</p>
  
  <pre><code>    @RequestMapping(value="/createMerchantAddress", method = RequestMethod.POST )
  public @ResponseBody String createMerchantAddress(@ModelAttribute("addressDTO") AddressDTO addressDTO,@AuthenticationPrincipal PNSolUser loggedUser){
      addressDTO.setPartyId(loggedUser.getPartyId());
      addressDTO.setCreatedBy(loggedUser.getUserId());
      addressDTO.setCreatedDate(Calendar.getInstance().getTime());
  </code></pre>