首页 新闻 会员 周边 捐助

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

0
悬赏园豆:5 [已解决问题] 解决于 2017-06-23 17:44

/**导出到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;
}

起风了~~~的主页 起风了~~~ | 小虾三级 | 园豆:691
提问于:2017-06-21 13:56
< >
分享
最佳答案
0

if(varOList.get(i).get("TOPICID")!=null){

vpd.put("var4", varOList.get(i).get("TOPICID").toString()); //4

}

收获园豆:5
小小小诚 | 菜鸟二级 |园豆:220 | 2017-06-23 16:59
其他回答(1)
0

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

吴瑞祥 | 园豆:29449 (高人七级) | 2017-06-21 13:59

话说在哪里判断呀

支持(0) 反对(0) 起风了~~~ | 园豆:691 (小虾三级) | 2017-06-21 14:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册