SpringMVC + ajax 上传文件不成功,用submit上传能实现

图片说明

你的前端页面代码时怎么写的?

HTML

<form id="excelForm" enctype="multipart/form-data">
      <input name="file" id="file" type="file"/>
      <input name="other" id="other" type="text"/>
</form>

ajax

var formData = new FormData($( "#excelForm" )[0]);
var url = "";
$.ajax({
       url: url,
       type: 'post',
       data: formData,
       dataType:'json',
       cache: false,
       contentType: false,
       processData: false,
       success: function(msg){
           alert(msg);
       }
 })

引入jquery-form.js

        $("#" + form).ajaxSubmit({type: 'POST', url: url, data: params, dataType: 'json',
            success: function (data, textStatus) {

            }, error: function () {
                return;
            }, beforeSend: function () {}, complete: function () {}
        });