1++++++++++++++++++++++++++++++
=====正确的
if(foundUserInfo != null)//判空
userInfo.setUserPassword(foundUserInfo.getUserPassword());//同步时,子系统的密码保持原值
addUserInfo(userInfo);
addUserColumnInfo(userInfo);
}
req.setPageCookie(rescenter.getPageCookie());
}
} catch (Exception e) {
log.error("", e);
}
} catch (Exception e) {
log.error("", e);
}
=====有bug的
userInfo.setUserPassword(foundUserInfo.getUserPassword());//同步时,子系统的密码保持原值
addUserInfo(userInfo);
addUserColumnInfo(userInfo);
}
req.setPageCookie(rescenter.getPageCookie());
}
} catch (RemoteException e) {
log.error("", e);
}
} catch (ServiceException e) {
log.error("", e);
}
=====总结
如果是RemoteException 、ServiceException则无法捕获为空的异常,从而待到程序出错,也不知道是哪儿出了错。
另外,变量判空一定要随时注意!!
2++++++++++++++++++++++++++++++
对hashMap的迭代.是先迭代key ,再迭代值的
java.util.HashMap a=new java.util.HashMap();
Iterator it= a.keySet().iterator();
while (it.hasNext())
{
Object key=it.next();//在迭代中,绝对不能多次出现it.next()!!!!!!!!!!!!!!!!!!
System.out.println("key:"+key);
System.out.println("value:"+a.get(key));
}