list与 null问题 大家帮下忙
<%
if (zhiXiaoPosList!=null){%>
<td width= "24% " colspan= "13 " align= "left "> <img src= "../images/dot1.gif "> <a href= " <%=request.getContextPath()%> /query/QueryZhiXiaoPos.jsp " target= "under "> <%=zhiXiaoPosseatnm%> 代销1 </a> </td>
<%} else if(nongHangList!=null ){
out.print( "888 "+nongHangList);
for (int i = 0; i < nongHangList.size(); i++) {
java.util.HashMap map = null;
map = (HashMap)nongHangList.get( i);
String seatno = map.get( "seatno ").toString();
String seatnm = map.get( "seatnm ").toString();
out.print(seatnm+ "*** ");
%>
<td width= "24% " colspan= "13 " align= "left "> <img src= "../images/dot1.gif "> <a href= " <%=request.getContextPath()%> /query/QueryDaiXiaoFund.jsp " target= "under "> <%=seatnm%> 代销 </a> </td>
<%
}
}else{ %>
<td width= "24% " colspan= "13 " align= "left "> </td>
<%
}
%>
zhiXiaoPosList 明是空,nongHangList有值 为什么不显示 <td width= "24% " colspan= "13 " align= "left "> <img src= "../images/dot1.gif "> <a href= " <%=request.getContextPath()%> /query/QueryDaiXiaoFund.jsp " target= "under "> <%=seatnm%> 代销代销代销 </a> </td>
而显示
<td width= "24% " colspan= "13 " align= "left "> <img src= "../images/dot2.gif "> <a href= " <%=request.getContextPath()%> /query/QueryZhiXiaoPos.jsp " target= "under "> <%=zhiXiaoPosseatnm%> 代销1 </a> </td>
------解决方案--------------------list虽然不空,可是里面没值
------解决方案--------------------if (zhiXiaoPosList!=null)
改成if(zhiXiaoPosList != null && zhiXiaoPosList.size()> 0)
试试
------解决方案--------------------同意楼上的,我想这就是引用类型的问题
比如ArrayList list1 = null;这时候无疑为空
而ArrayList list2 = new ArrayList();
这时候list2已经不为空了,只不过list2.size() == 0而已
不知道说的准不准确