今日份鸡汤:无论这个世界对你怎样,都请你一如既往的努力、勇敢、充满希望。
最近自己和身边的小伙伴都有一些事情发生,扰乱了思绪,也打破了自己安静学习的心,虽然到现在事情还没有结束,但是好在今天能够安静下来了,那就随便整理一些东西吧,今天这个简单
异常信息:
2021-12-16 11:15:34.983 WARN 19412 --- [nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of java.util.ArrayList
(although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('test'); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of java.util.ArrayList
(although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('test')<LF> at [Source: (PushbackInputStream); line: 3, column: 9] (through reference chain: domain.User["list"])]
demo展示:
@RestController
@RequestMapping(value="/", params = {"Action"})
public class RequestMappingDemo {
@RequestMapping(params = "Action=ParamTest")
public User myParamTest(@RequestBody User user) {
return user;
}
}
@Data
public class User {
private String name;
private List<String> list;
private int age;
}
postman请求:
image.png
从上图中不难看出,问题就出现在list参数值中,postman传进去的参数值类型与实际程序中的类型不一致导致的,那么更改一下重新访问一下就可以了:
image.png
网友评论