【发布时间】:2018-05-01 16:32:35
【问题描述】:
我需要使用我的 spring 控制器期望的 multipar 文件发送一个文件。
public void test(@RequestParam("file") MultipartFile file) {}
我知道我必须使用FormData,但我没能成功。这是我的代码:
this.headers = new Headers({ 'Content-Type': 'multipart/form-data'});
this.options = new RequestOptions({ headers: this.headers });
return this.http.post(environment.SERVER_ENDPOINT + 'parameters/area', formData, options)
.toPromise()
.then(this.extractData)
.catch(this.handleError);
【问题讨论】:
-
有什么问题?错误? formData 是否发送了类型文件?
标签: spring angular spring-mvc multipartform-data