Spring jackson message converter解析多余属性出错

问题:

实体类2个属性,传递的json三个属性,报404错误,Bad request.

配置如下:

 
        
            
                
                     
                        
                            NON_NULL
                        
                    
                
            
        
    


网上找的解决:

1.自定义mapper 配置到spring.xml中没卵用 
public class JacksonConvert extends ObjectMapper {

private static final long serialVersionUID = 1L;

public JacksonConvert() {
    super();
    this.setSerializationInclusion(Include.NON_NULL);
    this.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);//没生效
}

}

2.配置xml属性配置一个DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,没弄好到底怎么配置的。失败


最终解决:在你需要转换的bean上注解

@JsonIgnoreProperties (ignoreUnknown = true )

你可能感兴趣的:(SpringMvc-,Json转换-Jackson)