Java后端传Long类型给前端导致的精度丢失
作者:互联网
问题:实体属性是Long类型,在后端值本来是1119102511023023410,但是返回给前端的却是1119102511023023400
解决方案:添加序列化注解
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import java.io.Serializable; // 引入jackson的序列化类 public class Test implements Serializable { @JsonSerialize(using = ToStringSerializer.class) private Long testProperty; }
标签:jackson,后端,databind,Long,Java,import,序列化,class 来源: https://www.cnblogs.com/miaoying/p/11984741.html