我想上传图片和其他一些带有角度的表格。这是VM对象:
public class UserPictureVM {
private MultipartFile file;
private String type;
private String coverPosition;
这是rest方法:
@PostMapping("/user/upload-picture")
@Timed
public ResponseEntity<Void> uploadUserPicture(@RequestBody UserPictureVM userPicture){
这是提交表单的Angular方法:
saveCoverImage() {
const formData: FormData = new FormData();
formData.append('coverPosition', '0, 0');
formData.append('file', this.coverForm.file);
formData.append('type', 'cover');
this.profileService.uploadImages(formData)
.subscribe(res=> {
console.log(res);
})
}
但是我得到了错误:
Resolved exception caused by Handler execution: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;charset=UTF-8' not supported