各种bug和教训

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));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值