title: Spring4 MVC multiparts
body: <p>I am using Spring4 MVC and trying to upload a file along with some other input fields.</p>
  
  <p>I added multipart resolver in spring xml and jackson converter </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
     &lt;beans:property name="maxUploadSize" value="250000"/&gt;
     &lt;beans:property name="defaultEncoding" value="utf8" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;beans:bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"&gt;
    &lt;beans:property name="messageConverters" &gt;
      &lt;beans:list&gt;
         &lt;beans:ref bean="jacksonMessageConverter" /&gt;
      &lt;/beans:list&gt;
    &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>In my form I have declared it as <code>enctype="multipart/form-data"</code> and below is my ajax call</p>
  
  <pre class="lang-js prettyprint-override"><code>var oemManuals = new FormData();
  oemManuals.append("name",$( "#name" ).val());
  oemManuals.append("description",$( "#description" ).val());
  
   if($('#url').val()){
    oemManuals.append( 'url', $( '#url' )[0].files[0] );
  }
  
  $.ajax({  
      type: "POST",  
      url: "${pageContext.request.contextPath }/uploadManuals", 
      data:  oemManuals,
      processData: false,
      contentType: false,
      cache: false,
      dataType: "json",
  
      success: function(data){  
  </code></pre>
  
  <p>In my controller I tried through <code>@RequestParam</code> and request but getting a <code>required paramerter name is null</code>. Though I see the parameters are present  </p>
  
  <pre><code>@RequestMapping(value="/uploadManuals", method = RequestMethod.POST)
  public @ResponseBody List&lt;OEMManuals&gt; uploadManuals(HttpServletRequest request, 
                                                      @RequestParam MultipartFile url, 
                                                      HttpSession session) throws IOException{
  </code></pre>
  
  <p>All the values are null. </p>
  
  <p>Can someone please suggest if I am missing something. </p>
  
  <p>Thanks</p>