title: Uploading files using the Spring Framework and jquery-upload-file plugin issue
body: <p>I am having trouble uploading files via <strong>AJAX</strong> from my web-client to my Server. I am using the following <em>jQuery</em> library in the client-side to do the file upload: <a href="https://github.com/hayageek/jquery-upload-file" rel="nofollow">https://github.com/hayageek/jquery-upload-file</a></p>
  
  <p>In the server-side, I'm using <em>Spring Framework</em> and I have followed the following <em>Spring</em> Tutorial to build my Service: <a href="https://spring.io/guides/gs/uploading-files/" rel="nofollow">https://spring.io/guides/gs/uploading-files/</a></p>
  
  <p>At first, my server method looked like this (<em>file</em> was defined as <strong>@RequestParam</strong>):    </p>
  
  <pre><code>@RequestMapping(value="/upload", method=RequestMethod.POST)
  public @ResponseBody String handleFileUpload(@RequestParam("file") MultipartFile file){
      //functionality here
  }
  </code></pre>
  
  <p>but every time I submitted the Upload form I got a <strong>Bad Request</strong> message from the Server, and my <code>handleFileUpload()</code> method was never called.</p>
  
  <p>After that, I realized the file was not being sent as a Request Parameter so I defined <code>file</code> as <strong>@RequestBody</strong>, and now my method looks like this:</p>
  
  <pre><code>@RequestMapping(value="/upload", method=RequestMethod.POST)
  public @ResponseBody String handleFileUpload(@RequestBody("file") MultipartFile file){
      //functionality here
  }
  </code></pre>
  
  <p>Now <code>handleFileUpload()</code> is called every time the Upload form is submitted, but I am getting a <code>NullPointerException</code> every time I want to manipulate <em>file</em>.</p>
  
  <p>I want to avoid submitting the form by default, I just want to do it through AJAX straight to the Server. Does anybody know what could be happening here?</p>