【发布时间】:2021-01-21 09:09:09
【问题描述】:
我想将表单内的数据推送到我的 Spring REST api。处理程序方法如下所示:
@PostMapping
public RepresentationModel<?> handleFileUpload(
@RequestParam(value = "file") MultipartFile file,
@RequestParam(value = "description", required = false) String description,
@RequestParam(value = "public") Boolean publicAccessible,
@RequestParam(value = "access") @Valid List<SomeObject> access,
Authentication authentication) {
....
}
这给了我:
但我需要一种方法将复杂的对象包装到我的数组中。
这是我迄今为止唯一想到的。 我如何在 Postman 中塑造我的请求以满足我的控制器?问题是访问属性。 Spring 一直抱怨访问参数不存在或访问参数不是 List 类型。 在 Json 中,我的请求应如下所示:
"public": "true",
"description": "Bachelor Dokument",
"access": [
{
"someAttribute": "something",
"someAttribute2": "something"
},
{
"someAttribute": "something2",
"someAttribute2": "something2"
}
]
...
/*Content of uarttest.py*/
我需要表单数据来上传我想的文件。还是我在这里做错了什么? 提前致谢。
【问题讨论】:
标签: java spring rest file-upload postman