Spring Boot Jhipster映像上传不起作用

时间:2018-09-11 12:49:57

标签: java angular spring-boot jhipster

我想上传图片和其他一些带有角度的表格。这是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

0 个答案:

没有答案