`

org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field

阅读更多

使用Jackson 反序列化时,报错:

org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "age" (Class com.common.bean.RequestInfoBean), not marked as ignorable
 at [Source: java.io.StringReader@32deb93a; line: 1, column: 151] (through reference chain: com.common.bean.RequestInfoBean["age"])

 

原因:

把json字符串jsonStr ,反序列化为RequestBean,当jsonStr 中的字段,java bean中没有时报错

解决方法:

mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);

 

 

 

pom.xml:

<dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-lgpl</artifactId>
            <version>1.9.13</version>
        </dependency>

 参考:

http://blog.csdn.net/a9529lty/article/details/8232948

 

  • 大小: 60.9 KB
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics