springmvccontroller返回json出错解决 下载本文

org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:218)

org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:183)

org.codehaus.jackson.map.ser.std.SerializerBase.wrapAndThrow(SerializerBase.java:140)

3原因分析:

可能是json序列化的问题

代码修改为

@RequestMapping(value = "/query")

public @ResponseBody

Map<String, Object> query(@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime,

@RequestParam("oid") String oid, @RequestParam("cid") Integer cid, @RequestParam("pay_channel") String payChannel,

@RequestParam("device_type") String deviceType,

@RequestParam("phone") Integer phone,

@RequestParam("perPage") Integer pageSize,

@RequestParam("skipIndex") Integer startIndex) throws Exception {

LogInfo info = populateQueryParam(startTime, endTime, oid, cid, payChannel, deviceType, phone, pageSize, startIndex);

// 总记录数

Long totalCount = logMoniterService.queryLogInfoCount(info);

if (totalCount == null) {

totalCount = 0L;

}

List<LogInfo> list = logMoniterService.queryLogInfo(info);

Map<String, Object> result = new HashMap<String, Object>();

result.put("success", true);

result.put("data", list);

result.put("error", "");

result.put("totalRecords", totalCount);

return result;

}

4、问题解决