一个空指针异常,代码如下,打了断点,一到“TOPICID”那里(在下方注释4那里)就抛异常-_-||

/**导出到excel
* @param
* @throws Exception
*/
@RequestMapping(value="/excel")
public ModelAndView exportExcel() throws Exception{
logBefore(logger, Jurisdiction.getUsername()+"导出Entity到excel");
if(!Jurisdiction.buttonJurisdiction(menuUrl, "cha")){return null;}
ModelAndView mv = new ModelAndView();
PageData pd = new PageData();
pd = this.getPageData();
Map<String,Object> dataMap = new HashMap<String,Object>();
List<String> titles = new ArrayList<String>();
titles.add("表内id"); //1
titles.add("姓名"); //2
titles.add("实体类型"); //3
titles.add("topicid"); //4
titles.add("评论"); //5
// titles.add("0/1,1:已删"); //6
dataMap.put("titles", titles);
List<PageData> varOList = entityService.listAll(pd);
List<PageData> varList = new ArrayList<PageData>();
for(int i=0;i<varOList.size();i++){
PageData vpd = new PageData();
vpd.put("var1", varOList.get(i).get("ID").toString()); //1
vpd.put("var2", varOList.get(i).getString("NAME")); //2
vpd.put("var3", varOList.get(i).getString("ENTITYTYPE")); //3
vpd.put("var4", varOList.get(i).get("TOPICID").toString()); //4
vpd.put("var5", varOList.get(i).getString("COMMENTS")); //5
// vpd.put("var6", varOList.get(i).getString("DEL")); //6
varList.add(vpd);
}
dataMap.put("varList", varList);
ObjectExcelView erv = new ObjectExcelView();
mv = new ModelAndView(erv,dataMap);
return mv;
}

BIG阳
浏览 575回答 3
3回答

慕桂英3389331

if(varOList.get(i).get("TOPICID")!=null){ vpd.put("var4", varOList.get(i).get("TOPICID").toString()); //4 }

一只甜甜圈

varOList.get(i).get("TOPICID") 返回值判一下空.

拉莫斯之舞

话说在哪里判断呀
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java