public Map getSecondMap(Long id) {
Map<Long, String> secondMap=null;
FirstOutfit first=this.getFirstOutfitDao().findById(id);
Iterator it=first.getSecondOutfits().iterator();
while(it.hasNext()){
SecondOutfit second=(SecondOutfit)it.next();
Long secondId=second.getSecondOutfitId();//System.out.println()能正常打出来
String secondName=second.getSecondOutfitName();//System.out.println()能正常打出来
secondMap.put(secondId, secondName);
}
System.out.println("secondMapsize is:"+secondMap.size());//这句话不执行就报异常了 空指针异常
return secondMap;
}
代码如上:现在的问题是secondMap里面加不进东西去,报空指针异常..我实在整不明白咋回事了,请大家帮忙看看,谢谢....
Map<Long, String> secondMap=null;
FirstOutfit first=this.getFirstOutfitDao().findById(id);
Iterator it=first.getSecondOutfits().iterator();
while(it.hasNext()){
SecondOutfit second=(SecondOutfit)it.next();
Long secondId=second.getSecondOutfitId();//System.out.println()能正常打出来
String secondName=second.getSecondOutfitName();//System.out.println()能正常打出来
secondMap.put(secondId, secondName);
}
System.out.println("secondMapsize is:"+secondMap.size());//这句话不执行就报异常了 空指针异常
return secondMap;
}
代码如上:现在的问题是secondMap里面加不进东西去,报空指针异常..我实在整不明白咋回事了,请大家帮忙看看,谢谢....
解决方案 »
- 怎么样读取tomcat 下的properties文件
- java.lang.IllegalArgumentException: argument type mismatch 分数不多大家帮忙
- jsp网站与搜索引擎之间的问题
- 大家有用visio的没?哪个版本比较好用?给个下载地址,谢谢
- 关于在hibernate中多个sum求和问题
- 双击连接 跳转过后页面数据一片空白
- 新手求助!关于servlet ~~~~~~~~~~顺便默哀死难的同胞!
- Java 啊,怎么就那么缺工作啊??
- 能不能用浏览器打开的applet来控制web服务器上的程序或外部命令?
- 高分请教----这样的Tomcat怎么配?
- 一个小问题,求解~
- javamail发附件报错
这个map你一直都没有new出来
secondMap没有实力化
改成Map <Long, String> secondMap=new HashMap<Long,String>();