• 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:

  • 相关阅读:
    2021年2月22
    2021年2月21
    2021年2月20
    2021年2月19
    动态添加titie属性
    根据内容改变文字颜色!
    自定义弹出层!
    来回切换图标以及文字
    20180831xlVBA_WorksheetsCosolidate
    20180830xlVBA_合并计算
  • 原文地址:https://www.cnblogs.com/parkdifferent/p/7405405.html
Copyright © 2020-2023  润新知