• Serialize a Long as a String


      今天在写接口的时候,用postman测试,返回数据与数据库一一对应,但是给前端返回的结果,除了主键id以外,其他都一样,如下

    postman:

    {
                    "unitPrice": null,
                    "shoppingId": 898341460864172032,
                    "userId": 255,
                    "leadTime": null,
                    "buyNumber": 2,
                    "materialId": 106000001,
                    "materialCode": "0106000001",
                    "materialName": "油墨",
                    "brandId": 456,
                    "brandCode": "000246",
                    "brandName": "得力",
                    "materialPropertyFixed": "7521||40ml||号码机专用",
                    "unitId": 55,
                    "unitCode": "dascm055",
                    "unitName": "瓶",
                    "packageUnitId": null,
                    "packageUnitCode": null,
                    "packageUnitName": null,
                    "packageNumber": null,
                    "materialSetId": 10602010001,
                    "materialSetCode": "010602010001",
                    "materialSetName": "油墨",
                    "materialPhoteFile": "/dms/image/010602010001/XL_001.jpg",
                    "memo": null
                }

    前端结果:

    {
                    "unitPrice": null,
                    "shoppingId": 898341460864172000,
                    "userId": 255,
                    "leadTime": null,
                    "buyNumber": 2,
                    "materialId": 106000001,
                    "materialCode": "0106000001",
                    "materialName": "油墨",
                    "brandId": 456,
                    "brandCode": "000246",
                    "brandName": "得力",
                    "materialPropertyFixed": "7521||40ml||号码机专用",
                    "unitId": 55,
                    "unitCode": "dascm055",
                    "unitName": "瓶",
                    "packageUnitId": null,
                    "packageUnitCode": null,
                    "packageUnitName": null,
                    "packageNumber": null,
                    "materialSetId": 10602010001,
                    "materialSetCode": "010602010001",
                    "materialSetName": "油墨",
                    "materialPhoteFile": "/dms/image/010602010001/XL_001.jpg",
                    "memo": null
                }

      

      postman的shoppingId是  898341460864172032,前端的shoppingId是898341460864172000。

      解决方案是:

        @JsonSerialize(using = ToStringSerializer.class)
        private Long shoppingId;

     serialize a long as a string:

  • 相关阅读:
    Unable to satisfy the following requirements解决方式
    零基础学python》(第二版)
    mysql 更新数据表的记录
    mysql创建数据库和删除数据库
    正则表达式
    python lambda函数详细解析(面试经常遇到)
    Linux 命令 统计进程数目
    Python 时间戳与时间字符串互相转
    python 安装配置(windows)
    linux 系统 tar 的用法详解
  • 原文地址:https://www.cnblogs.com/parkdifferent/p/7405405.html
Copyright © 2020-2023  润新知