在使用Springboot框架开发系统时,想要上传多文件,遇到错误
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `[Lorg.hnu.precomputation.common.view.dataset.DatasetAddParam;` from Object value (token `JsonToken.START_OBJECT`); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `[Lorg.hnu.precomputation.common.view.dataset.DatasetAddParam;` from Object value (token `JsonToken.START_OBJECT`)
代码Controller层:
post请求:
遇到的错误
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `[Lorg.hnu.precomputation.common.view.dataset.DatasetAddParam;` from Object value (token `JsonToken.START_OBJECT`); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `[Lorg.hnu.precomputation.common.view.dataset.DatasetAddParam;` from Object value (token `JsonToken.START_OBJECT`)
解决方案:
多文件上传必须加@RequestParm()注解来确定上传的文件数组