@jsonProperty 实现返回自定义属性名字

实现场景: 比如说前端需要返回userPic 这个字段,但是我们数据库定义的是pic字段。

可以用@jsonProperty 来实现

public class User{
     @JsonProperty("pic")  
     String userPic; 
} 

 实现场景: 比如说我们返回前端的值为null就不让这个属性显示

spring:
    jackson:
        default-property-inclusion: non_null

 

posted @ 2019-02-08 14:39  发疯的man  阅读(3307)  评论(0编辑  收藏  举报