为了将文件从 Angular 上传到 Spring MVC REST WebService,人们似乎在 AJAX 请求中设置 Content-Type : undefined header 。
这种content-type的用途是什么,Spring MultiPart是否需要它?
$http.post(uploadUrl, fd, {
transformRequest : angular.identity,
headers : {
'Content-Type' : undefined
}
//...
}
最佳答案
它将重置默认 header “application/json”并让浏览器为我们填写正确的 Content-Type 以及正确的边界参数。
例如,手动设置为“multipart/form-data”将无法添加已经提到的边界。
关于javascript - AngularJS FileUpload 中未定义内容类型的用途,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41607656/