我可以在Spring中发布包含multipart / form-data的params数组

时间:2019-09-19 04:24:35

标签: java spring spring-boot request

Spring我可以发布具有multipart / form-data的params数组

@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public Object postData(@ModelAttribute DataDto request) {
  return request;
}

@Getter
@Setter
public class DataDto {
  private String number;
  private List<DetailDto> detail;
  private MultipartFile screenshot;
}

@Getter
@Setter
public class DetailDto {
  private String code;
  private String desc;
}

结果:

  

org.springframework.beans.InvalidPropertyException:Bean类[com.my.project.dto.DataDto]的无效属性'detail [0] [code]':在索引属性路径'detail [0] [code]中引用的属性]'既不是数组,也不是List也不是Map;返回值是[DetailDto(code = null,desc = null)]

这是用户界面

<form action="http://localhost:8081/test/multi" method="post" enctype="multipart/form-data">
<input name="number" value="number" autofocus>
<input type="file" name="screenshot">
<input name="detail[0][code]" value="code">
<input name="detail[0][desc]" value="desc">
<button>submit</submit>
</form>

1 个答案:

答案 0 :(得分:0)

请尝试以下代码:

touch -t 201801181205.09 data/dt=20190101/1.csv
touch -t 201801181205.09 data/dt=20190101/2.csv
  val df = spark.readStream
      .option("maxFileAge", "2d")
    .csv("data")

我希望这也会对其他人有所帮助:)