Spring Boot后端接收带文件内容的对象
- 后端接口代码
@PostMapping(value = "uploadTest", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public String upload(TestDTO dto){
return dto.getName();
}
- 接收对象代码
@Data
@ApiModel(value = "TestDTO", description = "测试实体")
public class TestDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键")
private String id;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("年龄")
private Integer age;
private MultipartFile[] photos;
-
Postman
-
测试结果