zoukankan      html  css  js  c++  java
  • 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:

  • 相关阅读:
    Python 标准库 BaseHTTPServer 中文翻译
    DBA Scripts
    cordova开发自己定义插件
    ASUS主板ALC887声卡,RTL81XX网卡,黑苹果驱动安装
    com.apple.installer.pagecontroller 错误 -1 pkg安装错误
    Apple 远程推送APNS 服务
    bitbucket git push 项目503失败
    在xcode5下利用Source Control 做 git 项目管理
    iOS设备定位服务开启判定
    has been modified since the precompiled header地图错误
  • 原文地址:https://www.cnblogs.com/parkdifferent/p/7405405.html
Copyright © 2011-2022 走看看