后端把Long类型的数据传给前端,前端可能会出现精度丢失的情况

       方法一:在后台将这个Long类型的字段转换成String类型的。

  方法二:使用fastjson的提供的注解,@JSONField(serializeUsing= ToStringSerializer.class)

比如数据表字段为数字Long类型

1、pom文件加入

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.71</version>
        </dependency>

2、对象基类加入

    @JSONField(serializeUsing = ToStringSerializer.class)
    @TableId(type = IdType.ASSIGN_ID)
    protected Long id;

 

相关文章:

  • 2021-08-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2021-07-05
  • 2022-12-23
相关资源
相似解决方案