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:

  • 相关阅读:
    EasyUI Combobox组合框(模糊搜索、默认值绑定)
    Asp.Net下载文件时中途失败问题
    VS使用小技巧之——设置调试时启动项目和启动页
    VS使用小技巧之——给代码添加region
    VS使用小技巧之——引入整个文件夹
    VS使用小技巧之——任务列表
    FineUI给表格行内链接设置弹出窗体
    cnpm私服搭建和发布包
    阿里云产品术语和docker
    angularjs1.x的一些知识点整理
  • 原文地址:https://www.cnblogs.com/parkdifferent/p/7405405.html
Copyright © 2011-2022 走看看