使用postMan测试接口时出现上述问题:
后来发现我返回的map中的key出现了null值,所以才会出现上述错误,记录下来,下次再碰到就知道怎么搞了。
如下代码:返回的map中出现了null值
@RequestMapping(value="/selectTrafficJeevesByDistict")
public Map selectTrafficJeevesByDistict() {
List<TrafficJeevesDistrictCount> list = this.selectTrafficJeevesByDistict1();
Map map = new HashMap<>();
for (TrafficJeevesDistrictCount t : list) {
map.put(t.getDistrictInfo(), t.getDistrictCount());
}
int others = 0;//其他施工总数
int total = trafficeJeevesServer.selectTotalCounts();//实时施工总数
int i = 0;//top5总数
for (TrafficJeevesDistrictCount t : list) {
String count = t.getDistrictCount();
if(count != null && count != "") {
int a = Integer.parseInt(count);
i = a + i;
}
}
others = total - i;
map.put("total", total);
map.put("i", i);
map.put("其他", others);
return map;
}