Angular 5:将带有字符串参数和 FormData 参数的 POST 请求一起发送到 Spring REST 控制器

Angular 5: Sending POST request with string parameters and FormData parameter together, to a Spring REST Controller

我想从我的服务向 SpringBoot @RestController 发送一个 POST 请求。我有一堆要发送的字符串参数,但我还有一个 FormData 参数,它是一个图像(图片参数)。如果我这样做:

  public createEvent(name, description, fromDate, toDate, userId, picture){
      this.http.post(this.baseUrl + 'create',
          {
              name: name,
              description: description,
              fromYear: fromDate['year'],
              fromMonth: fromDate['month'],
              fromDay: fromDate['day'],
              toYear: toDate['year'],
              toMonth: toDate['month'],
              toDay: toDate['day'],
              userId: userId,
              picture: picture
          }).subscribe();
  }

我的控制器方法如下所示:

@PostMapping(value = "/create")
    public void createEvent(@RequestBody Map map){}  

地图看起来像这样:

我无法获取文件。
我可以在 post 请求中将 FormData 作为单个参数发送,并在我的控制器中将其作为多部分文件接收而没有任何问题,但是是否可以在同一请求中将其与其他参数一起发送?

显然,您可以将所有参数附加到 FormData 对象中,并通过控制器中的@RequestParam 访问它们。