F12控制台后端返回的long类型ID后两位变为0
如图所示问题:

这个是精度丢失问题,就是前端JS的精度没有那么高
解决方法
在spring MVC 中新建一个转换配置,在转JSON数据的时候,将Long类型转为String即可
/**
* Spring MVC Jackson 配置
*/
@JsonComponent
public class JsonConfig {
/**
* 添加一个转换器,将Long类型的数据转为String类型
* 避免在前端显示的时候,出现精度丢失的问题
* @param builder
* @return
*/
@Bean
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder){
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
SimpleModule module = new SimpleModule();
module.addSerializer(Long.class, ToStringSerializer.instance);
module.addSerializer(Long.TYPE, ToStringSerializer.instance);
objectMapper.registerModule(module);
return objectMapper;
}
}