zoukankan      html  css  js  c++  java
  • dto 返回 null 的处理 (必须或非必须字段控制)

    1. 如果要dto 上不显示 null 值的直段那么使用注解
    @Data
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public class OrderDTO {
        //todo
    }

    2. 配置全局的设置可以在yml 配置文件

    spring:
      datasource:
        driver-class-name: com.mysql.cj.jdbc.Driver
        username: root
        password: 
        url: jdbc:mysql://localhost:3306/sell?serverTimezone=GMT%2B8&characterEncoding=utf-8&userSSL=false
      jpa:
        show-sql: true
      jackson:
        default-property-inclusion: non_null

    3.要字段必须返回

    public class OrderDTO {
    
        private String orderId;
        private String buyerName;
        private String buyerPhone = "";
    }
  • 相关阅读:
    thinkphp目录解析
    开发规范
    form
    命名空间
    类与对象
    OS知识点汇总
    C++每日一记!
    语言哲学和语言逻辑
    形式语言与自动机
    C#脚本
  • 原文地址:https://www.cnblogs.com/qinls/p/10056521.html
Copyright © 2011-2022 走看看