我正在尝试将具有其他参数的多个文件从客户端上传到服务器。
我的AJAX是:
files: (binary)
files: (binary)
arrStr: [{"name":"aa","file":"Test PDF 2.pdf","status":"on"},{"name":"bb","file":"TEST PDF.pdf","status":"on"}]
我的控制器是:
@PostMapping(value = "/saveUploadFileListing", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public String saveUploadFileListing(
@RequestParam(value="files", required = false) MultipartFile [] file,
@RequestParam(value="arrStr") FileManagementSaveWrapper arrStr) {
List<FileManagementSaveDTO> files = arrStr.getFileManagement();
我的FileManagementSaveWrapper是:
@Data
public class FileManagementSaveWrapper {
private List <FileManagementSaveDTO> fileManagement;
}
我的FileManagementSaveDTO是:
@Data
public class FileManagementSaveDTO {
private String name;
private String file;
private String status;
}
但是问题是:
[org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException: Failed to convert value of type 'java.lang.String' to required type 'com.nera.nms.dto.FileManagementSaveWrapper';
nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'com.nms.dto.FileManagementSaveWrapper': no matching editors or conversion strategy found]
我不确定为什么不能将String授予包装类。
请帮助。谢谢。