spring mvc 返回的json去掉null

在springmvc.xml中添加如下:


           
               
                   
                       NON_NULL
                   
               
           
        

但是有个问题就是以json作为参数的接口,bean必须和json对应好,否则会报

 at [Source: java.io.PushbackInputStream@4053f24; line: 1, column: 100] (through reference chain: com.neusoft.geexek.web.enroll.bean.
CompetitionRoadUser["IDNumber"]);
 nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "IDNumber" (class com.neusoft.geexek.web.
enroll.bean.CompetitionRoadUser),
 not marked as ignorable (54 known properties: "remark", "sumAmount", "groupNum", "shoesSize", "userMapId", "isTeamLeader", "platForm", "payTime",
 "dateOfBirth", "email", 
"isPay", "contactsAddress", "cert", "origin", "isTeam", "clothingSize", "auditStatus", "callPhone", "roleId", "updateTime", "trueName", "gender",
 "idNumber", "degree", "lot", "bloodType", "teamId", "contactsPhone", "health", "serialNumber", "noteIsSend", "createTime", "city", "payOrigin",
 "contactsRelation", "extraPayAmount", "note", "address", "isDelete", "userName", "teamSave", "extraPays", "contactsName", "typeOfID", "userPayRelations",
 "registerId", "cmptId", "isCancel", "amount", "roadId", "team", "isIns", "markNo", "role"])
 at [Source: java.io.PushbackInputStream@4053f24; line: 1, column: 100] (through reference chain: 
com.neusoft.geexek.web.enroll.bean.CompetitionRoadUser["IDNumber"])

我传递的json格式的参数数:

{"remark":"[]","userName":"123123123","callPhone":"123123123123","typeOfID":"身份证","IDNumber":"123123123123123","gender":0,"roadId":8553,"userPayRelations":[],"idNumber":"123123123123","isIns":2}


去除这种错误的办法:在bean上添加

@JsonIgnoreProperties(ignoreUnknown = true)

你可能感兴趣的:(springmvc,json,Jackson)