JSON parse error: Cannot deserialize value of type `java.util.ArrayList<java.lang.Long>` from Object value (token `JsonToken.START_OBJECT`); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.util.ArrayList<java.lang.Long>` from Object value (token `JsonToken.START_OBJECT`)\n at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 1]
接口:
public AjaxResult editList( String unit, String ruleValue, @RequestBody List<Long> ids){}
第一次写后端接口 前端传过来三个参数, 其中一个参数类型为id组成的数组, 后端对这个ID数组的类型设置成List<Long>类型, 请求接口报上面的错误,后来给ids前面加了个@RequestBody注解 再次请求又报下面这个错:
Uncaught (in promise) Error: Required request parameter 'ruleIds' for method parameter type List is not present
最后无奈改了前端的请求接口:
export function updateList(data) {
return request({
url: `/aaa/list?unit=${data.name}&ruleValue=${data.value}`,
method: 'put',
data: data.ids
})
}