邮递员:创建复杂的MULTIPART_FORM_DATA请求

时间:2018-10-16 08:05:25

标签: spring spring-boot postman

我需要使用邮递员创建一个请求。 Spring Boot端点为:

@RequestMapping(
    value = "/group",
    method = RequestMethod.POST,
    consumes = MediaType.MULTIPART_FORM_DATA_VALUE
)
public ResponseEntity<String> group(
    @RequestPart("items") List<ItemType> items,
    @RequestPart("group") GroupType group);

其中:

public class ItemType {
  private String description;
  private String security;
  private Date bestdate;
  private MultipartFile content;
}

public class GroupType {
  private String description;
  private String security;
  private String metadata;
}

如您所见,ItemType包含一个MultiPartFile

我的意思是,我需要在"items""group"部分上写什么:

enter image description here

1 个答案:

答案 0 :(得分:0)

Postman中有一个选项可以提供表单数据,您可以在其中传递文本和文件。

主体的json部分也应设置为“文件”而不是“文本”,并将json数据放入json文件中,例如“ a.json”。 检查以下内容,希望对您有所帮助。 enter image description here