springmvc+jackson不返回null值

jackson目前有两个大版本:目前最新(2014/9/7)的release版分别是1.9.13和2.4.2。

1.9.13版本所需最少jar包:jackson-core-asl-1.9.13.jar和jackson-mapper-asl-1.9.13.jar共2个。

其中值为null不返回时注解是:@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)

                                           需要:import com.fasterxml.jackson.databind.annotation.JsonSerialize;


2.4.2版本中所需最少jar包:jackson-core-2.4.2.jar和jackson-annotations-2.4.2.jar和jackson-databind-2.4.2.jar共3个。

其中值为null不返回时注解是:@JsonInclude(JsonInclude.Include.NON_NULL)

                           需要:import com.fasterxml.jackson.annotation.JsonInclude;

jackson-databind-2.4.2.jar必须有,要不然会报错。

主要错误信息:HTTP Status 406

                            The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.

你可能感兴趣的:(jackson,springmvc,jackson,null)