首页 前端知识 JSON parse error: Cannot deserialize value of type `java.util.ArrayList<java.lang.Long>` from Object

JSON parse error: Cannot deserialize value of type `java.util.ArrayList<java.lang.Long>` from Object

2024-05-12 17:05:57 前端知识 前端哥 281 127 我要收藏

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
  })
}
复制

转载请注明出处或者链接地址:https://www.qianduange.cn//article/8439.html
标签
评论
还可以输入200
共0条数据,当前/页
发布的文章

JQuery中的load()、$

2024-05-10 08:05:15

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!