Heim > Fragen und Antworten > Hauptteil
"id" : 24787807536939046,
"acId" : 24768209282400257,
"insertTime" : 1476957265000,
"lastUpdateTime" : 1476957265000,
这里返回的id,acid因为是long类型,如果数值太大在js里会失真,怎么在返回的时候让24787807536939046为string类型,通过注解
三叔2016-11-16 15:13:08
自定义ObjectMapper,会自动把Long类型转成string到前端
public class CustomObjectMapper extends ObjectMapper { private static final long serialVersionUID = 3223645203459453114L; /** * 构造函数 */ public CustomObjectMapper() { super(); SimpleModule simpleModule = new SimpleModule(); simpleModule.addSerializer(Long.class, ToStringSerializer.instance); simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); registerModule(simpleModule); }