繁体   English   中英

解决com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:无法识别的字段

[英]resolving com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field

这个例子对我的日食很有效。 但是,当我将Person类更改为以下内容时:

package com.thejavageek.jaxrs.model;

public class Person {


private int userSelectList;

    public int getUserSetSelectList() {
        return userSelectList;
    }

    public void setUserSetSelectList(int userSelectList) {
        this.userSelectList = userSelectList;
    }





    @Override
    public String toString() {

        return "Person [userSelectSet=" + userSelectList + "]";
    }

}

我通过传递JSON进行了如下测试:

在此处输入图片说明

错误:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "userSelectList" (class com.thejavageek.jaxrs.model.Person), not marked as ignorable (one known property: "userSetSelectList"])
 at [Source: io.undertow.servlet.spec.ServletInputStreamImpl@6418702f; line: 1, column: 20] (through reference chain: com.thejavageek.jaxrs.model.Person["userSelectList"])

为什么我在上面共享的链接的示例形式可以正常工作而不是这个?

在您的json中,将“ userSelectList”更改为“ userSetSelectList”,或将您的setter更改为“ setUserSelectList”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM