zoukankan      html  css  js  c++  java
  • 页面输出格式常用注解----@JsonIgnore,@JsonFormat,@JsonFormat

    1.注解名称:@JsonIgnore 作用:在实体类向前台返回数据时用来忽略不想传递给前台的属性或接口。 Eg:User实体中会有字段password字段,

    当返回用户信息给前台的时候,当然是不希望将password值也一并返回。所以,这个时候可以在password属性上加上注解JsonIgnore或者,

    可以在User类上加上注解@JsonIgnoreProperties(value = "{password}")

    2.注解名称:@JsonFormat

    前台使用固定时间格式时可以在属性名上添加@JsonFormat注解()

    不返回null字段数据

    3.注解名称:@JsonFormat

    在相关对象的类上添加 @JsonInclude 注解,设定值为 NON_NULL

    例子:
    @JsonIgnore
    private String password;
    private Integer age;
    @JsonFormat(pattern="yyyy-MM-dd hh:mm:ss a", locale="zh", timezone="GMT+8")
    private Date birthday;
    @JsonInclude(Include.NON_NULL)
    private String desc;

  • 相关阅读:
    vim代码对齐
    在liunx中,快速查找到以前使用过的命令行
    linux文件权限与目录设置
    ASP常用代码
    存储过程
    WebService
    SNS
    浪曦博客系统
    SQL事件探查器与索引优化向导
    光盘AJAX
  • 原文地址:https://www.cnblogs.com/libaowen609/p/12677058.html
Copyright © 2011-2022 走看看