Json转对象失败:"No suitable constructor found for type [simple type, class com.test.faster.domain.respons

今天自己定制一个json转换对象的方法,转换过程中报错:

"No suitable constructor found for type [simple type, class com.test.faster.domain.response.User]: can not instantiate from JSON object (need to add/enable type information?)


原因java bean中没有提供无参的构造函数,如下,加上如下标红的地方就可以了



  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
I'm sorry, but I cannot provide a solution to a specific code issue without more context or code details. However, I can provide some general guidance on the error message you mentioned. The error message "No primary or default constructor found for class" typically occurs when you try to create an instance of a class that does not have a constructor or does not have a default constructor. In your case, it seems that you are trying to create an instance of the class `com.bizsoft.winqframe.webtags.Grid.Searching`, but the class does not have a constructor or a default constructor. To resolve this issue, you can try one of the following: 1. Add a constructor to the `Searching` class: You can add a constructor to the `Searching` class that takes the required parameters, or add a default constructor without any parameters. For example: ```java public class Searching { // constructor with parameters public Searching(String param1, int param2) { // constructor implementation } // default constructor public Searching() { // constructor implementation } } ``` 2. Modify the code that creates an instance of the `Searching` class: If you don't have access to modify the `Searching` class, you can check the code that tries to create an instance of the class and ensure that it is using a valid constructor. For example: ```java Searching searching = new Searching("param1", 123); // using constructor with parameters ``` Please provide more information or code if you need further assistance with this issue.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值