java - form-data file upload + array of object
问题描述
I want to push data inside a form to my Spring REST api. The handler method looks as follows:
@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) {
....
}
this gave me:
But I need a way to wrap a complex Object into my array.
This is the only thing I came up with so far. How do I have to shape my request in Postman to satisfy my controller? The problem is the access attribute. Spring complains all the time access parameter is not present or access parameter is not of type List. In Json my request should look like this:
"public": "true",
"description": "Bachelor Dokument",
"access": [
{
"someAttribute": "something",
"someAttribute2": "something"
},
{
"someAttribute": "something2",
"someAttribute2": "something2"
}
]
...
/*Content of uarttest.py*/
I need the form-data for uploading files I figured. Or do I do something wrong here? Thanks in advance.
解决方案
推荐阅读
- plugins - 对于我的 Outlook 插件清单文件。为什么我不能把“IdentityAPI”放在Requirements>Sets 中?
- jquery - 使用数据表在多个表中进行列搜索
- mongodb - 当我使用mongodb的map-reduce时,它为什么会嵌套?
- php - 如何对具有按 id 选择的外部值的列求和
- google-chrome-devtools - 当 DOM 元素从其父元素中移除时如何中断?
- c# - C# 在 WinForm 中正确设计 RDLC 报告
- reactjs - React:如何通过按下按钮来复制子组件?
- drupal - 聚合器模块 - entityref 错误
- python - AttributeError:“dict”对象没有属性“plot”
- javascript - 如何将名称属性放入Angular js Material中的md-select?