@JsonIgnore注解 忽略某个字段不展示给前端

@JsonIgnore注解

作用:在json序列化时将pojo中的一些属性忽略掉,标记在属性或者方法上,返回的json数据即不包含该属性。

@Table(name = "tb_user")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
 
    private String username;// 用户名
 
    @JsonIgnore
    private String password;// 密码
 
    private String phone;// 电话
 
    private Date created;// 创建时间
 
    @JsonIgnore
    private String salt;// 密码的盐值
    
    //TODO  add getter setters
}

 

 
 
posted @ 2022-04-19 14:52  古家杰  阅读(1247)  评论(0)    收藏  举报