看不懂空指针,没救了,很不幸说的是我自己
List<CarNoModel> carNoResult = incomingService.queryCarNo(carNoModel,sysName); if(carNoResult != null) { model.addObject("list", net.sf.json.JSONArray.fromObject(carNoResult)); }else { CarNoModel c = new CarNoModel(); c.setCarNo("未查到数据"); carNoResult.add(c); model.addObject("list", net.sf.json.JSONArray.fromObject(carNoResult)); }
当 carNoResult没空的时候,null当然就加不了啊,也就add不了啊,真的是睿智了,----------------------------------
所以要,再new一个出来啊,笨啊遭人嫌弃啊,carNoResult = new ArrayList<carNoResult>();
List<CarNoModel> carNoResult = incomingService.queryCarNo(carNoModel,sysName); if(carNoResult != null) { model.addObject("list", net.sf.json.JSONArray.fromObject(carNoResult)); }else { CarNoModel c = new CarNoModel(); c.setCarNo("未查到数据"); carNoResult = new ArrayList<CarNoModel>(); carNoResult.add(c); model.addObject("list", net.sf.json.JSONArray.fromObject(carNoResult)); }
好好学习,天天向上