title: 415 unsupported media type
body: <p>I have got a form with file upload and sometimes I'm catching <code>415 unsupported media type</code> with no messages in log. This is my form:</p>
  
  <pre><code>&lt;form:form method="post" enctype="multipart/form-data"
      class="form-horizontal" modelAttribute="massSMSForm"
      style="width: 650px;"&gt;
  
      &lt;c:if test="${!empty errorFlag}"&gt;
          &lt;div class="alert alert-danger"&gt;
              &lt;a href="#" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/a&gt; &lt;b&gt;Ошибка.
              &lt;/b&gt;
              &lt;form:errors path="*" /&gt;
  
          &lt;/div&gt;
      &lt;/c:if&gt;
      &lt;div class="well" style="width: 650px;"&gt;
  
          &lt;table style="width: 100%"&gt;
  
              &lt;tr&gt;
                  &lt;td align="left"&gt;&lt;b&gt;Наименование рассылки*&lt;/b&gt;&lt;/td&gt;
                  &lt;td align="right"&gt;&lt;form:input path="title" type="text"
                          class="form-control" id="title" style="width:340px;"
                          maxlength="15" /&gt;&lt;br /&gt;&lt;/td&gt;
              &lt;tr&gt;
                  &lt;td align="left"&gt;&lt;b&gt;Отправитель*&lt;/b&gt;&lt;/td&gt;
                  &lt;td align="right"&gt;&lt;form:input path="from" type="text"
                          maxlength="15" class="form-control" id="from" style="width:340px;" /&gt;&lt;br /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td align="left"&gt;&lt;b&gt;Дата начала рассылки&lt;/b&gt;&lt;/td&gt;
                  &lt;td align="right"&gt;&lt;form:input id="deliveryDate"
                          path="deliveryDate" type="text" autocomplete="off"
                          class="form-control" placeholder="сейчас" style="width:310px;" /&gt;&lt;br /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td align="left"&gt;&lt;b&gt;Срок жизни&lt;/b&gt;&lt;/td&gt;
                  &lt;td align="right"&gt;&lt;form:input id="expiration" path="expiration"
                          type="number" min="1" max="72" autocomplete="off"
                          class="form-control" placeholder="в часах" style="width:310px;" /&gt;&lt;br /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td align="left"&gt;&lt;b&gt;Файл рассылки*&lt;/b&gt;&lt;/td&gt;
                  &lt;td align="right"&gt;&lt;input type="file" name="file"
                      accept="text/xml, text/plain" id="mass" /&gt;&lt;br /&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
          &lt;/table&gt;
  
  
          &lt;br /&gt; &lt;b&gt;Текст сообщения рассылки&lt;/b&gt;&lt;br /&gt; &lt;br /&gt;
          &lt;c:choose&gt;
              &lt;c:when test="${massSMSForm.ignore==false}"&gt;
                  &lt;form:textarea path="message" class="form-control" rows="5"
                      id="message" placeholder="..." maxlength="500" /&gt;
  
              &lt;/c:when&gt;
  
              &lt;c:otherwise&gt;
                  &lt;form:textarea path="message" class="form-control" rows="5"
                      id="message" placeholder="..." disabled="true" maxlength="500" /&gt;
  
              &lt;/c:otherwise&gt;
          &lt;/c:choose&gt;
  
  
  
  
          &lt;br /&gt;
          &lt;form:checkbox path="ignore" id="ignoreBox" /&gt;
          &lt;small&gt;Игнорировать сообщение&lt;/small&gt;
  
  
      &lt;/div&gt;
  
  
  
      &lt;div style="text-align: right"&gt;
          &lt;a href="/${initParam['appName']}/userRole/"
              class="btn btn-link btn-sm"&gt;Назад&lt;/a&gt;&lt;input
              class="btn btn-success btn-sm" type="submit" name="send"
              onclick="myAlert()" value="Отправить" /&gt;
      &lt;/div&gt;
  
  
  &lt;/form:form&gt;
  
  
  &lt;script type="text/javascript"&gt;
      function confirmSend() {
          if (confirm("Отправляем сообщения?")) {
              return true;
          } else {
              return false;
          }
      }
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
      jQuery('#deliveryDate')
              .datetimepicker(
                      {
                          lang : 'ru',
                          i18n : {
                              ru : {
                                  months : [ 'Январь', 'Февраль', 'Март',
                                          'Апрель', 'Май', 'Июнь', 'Июль',
                                          'Август', 'Сентябрь', 'Октябрь',
                                          'Ноябрь', 'Декабрь', ],
                                  dayOfWeek : [ "Вс", "Пн", "Вт", "Ср", "Чт",
                                          "Пт", "Сб", ]
  
                              }
                          },
                          dayOfWeekStart : 1,
                          timepicker : true,
                          format : 'Y-m-d H:i'
                      });
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
      document.getElementById('ignoreBox').onchange = function() {
          document.getElementById('message').disabled = this.checked;
      };
  &lt;/script&gt;
  </code></pre>
  
  <p>And method:</p>
  
  <pre><code>@RequestMapping(value = "/sms/mass", method = RequestMethod.POST, headers = "content-type=multipart/form-data")
  public String massSMSProcess(Map&lt;String, Object&gt; map,
          @ModelAttribute("massSMSForm") MassSMSForm massSMSForm,
          BindingResult result, HttpSession session) throws IOException {
  
      session.removeAttribute(SESSION_KEY);
  
      massSMSFormValidator.validate(massSMSForm, result);
  
      if (result.hasErrors()) {
          map.put("errorFlag", true);
          return massSMSPage(map, massSMSForm, session);
      } else {
          try {
              SMS sms = SmsBuilder.build(massSMSForm);
              session.setAttribute(SESSION_KEY, sms);
              map.put("title", "Подтверждение операции");
              map.put("count", sms.getSmsEntityList().size());
          } catch (IOException e) {
              // mailer.send("/sms/mass :" + e.getMessage() + "form:"
              // + massSMSForm);
  
              map.put("error", "Ошибка ввода/вывода");
              return distributionListPage(map);
          }
          return "confirmMassSMSPage";
      }
  }
  </code></pre>
  
  <p>What is wrong? Is it js problem or what? Should I add new headers? What's your thoughts?</p>