开发者社区> 问答> 正文

SpringMVC用@RequestBody反序列化时出错?报错

public Object selectByExample(@RequestBody SysRole sysRole)

json是这样的

{"id":"","rolename":"root","sort":"","info":"","lastModifyTime":"","status":"","pageNum":"1","pageSize":"2"};

实体类SysRole是这样的

public class SysRole extends MyPage implements Serializable{
    private Integer id;

    private String rolename;

    private Integer sort;

    private String info;

    private Date lastModifyTime;

    private Integer status;


public class MyPage implements Serializable{
    //当前页
    private int pageNum=1;
    //每页的数量
    private int pageSize=10;



get和set省略



报错:com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.dongwukj.domain.sys.SysRole out of START_ARRAY token





展开
收起
爱吃鱼的程序员 2020-06-12 15:18:39 868 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    解决了,是自己太大意了,应该传入json字符串的,结果自己写成了json对象,去墙角默默反省<spanstyle="font-size:13.3333330154419px;">sort":""确定能转成<spanstyle="font-size:13.3333330154419px;">private<spanstyle="font-family:Consolas,'BitstreamVeraSansMono','CourierNew',Courier,monospace;font-size:14px;line-height:15.3999996185303px;background-color:#FFFFFF;"> <spanstyle="font-size:13.3333330154419px;">Integersort?确认过了,sort改成0依然报错,应该与SysRole的继承有关系,但不知道怎么解决

    传入的JSON格式有问题,

    你懂得 <imgsrc="http://www.oschina.net/js/ke/plugins/emoticons/images/21.gif"alt="">

    不明白,大神求教

    2020-06-12 15:18:56
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载