最近再弄springboot,再上传文件时出现【MultipartException: Current request is not a multipart request】的错误
以下是需要检查的点:
1.页面<head></head>标签里面加上<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
原因请看http://www.tuicool.com/articles/FrY7Fv
2.from表单的属性设置里面加上enctype="multipart/form-data"
原因请看http://zkliqiang.iteye.com/blog/779285
3.ajax提交需要加上processData和contentType,因为ajax提交时,contentType默认是 "application/x-www-form-urlencoded"。
$.ajax({
url: "/customer/customerManageImport",
data: formData,
processData: false, //因为data值是FormData对象,不需要对数据做处理。
contentType: false,
type: "POST",
success: function(ret) {
}
});