title: Spring boot: The request was rejected because no multipart boundary was found in spring boot with ajax call?
body: <p>I am working with Spring boot. I want to upload a file along with some data using an AJAX call. However, when I enter the data, select the file, and click the submit button, I get the following exception:</p>
  
  <blockquote>
    <p>org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found </p>
  </blockquote>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form  id="course-form" enctype="multipart/form-data"&gt;
    &lt;input type="text" class="form-control" placeholder="Course Name" name="courseName" id="courseName"&gt;
    &lt;input type="text" class="form-control" placeholder="Total no of sets" name="noOfSets" id="noOfSets"&gt;
    &lt;input type="text" class="form-control" placeholder="Total fees" name="fees" id="fees"&gt;
    &lt;input type="file" class="form-control" placeholder="Select an image" name="image" id="image"&gt;
    &lt;input type="text" name="requirements" id="requirements" class="form-control"&gt;
    &lt;input type="text" name="requirements" id="requirements" class="form-control"&gt;
    &lt;input type="button" value="Add more requirements" id="add-req"&gt;
    &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>ajax call</p>
  
  <pre><code>function saveCourse(){
               var itemData=new FormData($("#courseForm")[0]);
              $.ajax({
                  type : "POST",
                  url : "/course/save",
                  data : itemData,
                  async: false,
                  processData : false,
                  cache : false,
                  contentType : 'multipart/form-data',
                  success : function(result) {
                      if(result.message !=null){
                      alert(result.message);
                      }
                  },
                  error : function(e){
                      alert("Error! Please enter proper data");
                  }
              });
              return false;
          }
  </code></pre>
  
  <p>Controller class</p>
  
  <pre><code>@PostMapping(value="/course/save")
  public ResponseDTO addCourse(MultipartHttpServletRequest request, CourseDTO courseDTO) 
  {
    System.out.println("Course controller save menthod started");
    return null;
  }
  </code></pre>
  
  <p>Why am I receiving this exception? And, how can I solve the problem?</p>