title: post object to spring mvc, all fields are null
body: <p>i would like to pass a object and validate it.
  JavaScript:</p>
  <pre><code>var pic = {
           &quot;picture&quot;:file,
           &quot;ext&quot;:&quot;png&quot;
    }
  
  fetch(url, {
        method: 'POST',
        body: pic
      }).then(response =&gt; {
          if(response.status === 201){
              console.log('saved!!!');
              getPicture('no-cache');
          }
      })
  </code></pre>
  <p>My Controller is looking like that:</p>
  <pre><code>@PostMapping(value = &quot;/user-pic&quot;)
      public ResponseEntity&lt;String&gt; submit(@Valid @ModelAttribute(&quot;pic&quot;) PictureDTO pictureDTO,
                                           BindingResult result, Model model,
                                           @AuthenticationPrincipal UserDetails userPrincipal) throws IOException {
  ...
  }
  </code></pre>
  <p>My dto object is:</p>
  <pre><code>@NoArgsConstructor
  @AllArgsConstructor
  @Data
  public class PictureDTO {
      MultipartFile formDataWithFile;
      String pictureExtension;
  }
  </code></pre>
  <p>And my validator</p>
  <pre><code>public class PictureValidator implements Validator {
  
  ...
          @Override
      public void validate(Object target, Errors errors) {
          try {
              //boths fields of this object are null
              //but validator will be triggered
              final PictureDTO pictureDTO = (PictureDTO) target;
       }
  }
  </code></pre>
  <p>How can i fix it, to pass object from java-script to validator and my Fileds: MultipartFile and String will not be null anymore?</p>