??????????j2ee????校???????????????些??????????????尾??????????????????????????芯?墨????????锌??????些??????????????????

???????????????????????????????????????些?????????小???????????????????????????????????位???????????????????椤�

??????spring+struts2+hibernate??????????????????????????????????action???????谓mvc??controller??????action????????????service??servce?????贸?貌?dao????????????薪????????action????????action??????????????妫�?????????????????

??????????????????锌??????????????dao????????SQLException??service???????NullPointException??action???????IOException???????????????????未???????????貌???????????校????????????????????????????dao??service??action??未???????????????????????????????????????????????????妫�???????????????

?????????????????????????????澹�?????????????????????????????

???????java???????????????????????????????throws?????尾??????写try...catch????catch???胁????魏尾????????????printStackTrace()??????????????????????????????????????????????????????????娌�??????????????????????????????????????bug???????????????????

?????????????????????????????????????java???????????????????????????action???????????????????????log???????????????????????????????????????????????????

 

//???????????
Log log = LogFactory.getLog(this.getClass());
 
//action???????????????
public String save(){
   try{
         //????service??save????
         service.save(obj);
   }catch(Exception e){
         log.error(...);   //???log???
      return "error"; ?????error???
   }
   return "success";
}

 ????????????????????????????????????????????????????????????????????????????????????????????

???????????????????????????????????????些?????????????????????????????????????????????

?????????spring???????????????????????????????RuntimeException?????3????????????????????y???try...catch????

??????????????????写try...catch??????catch????????????????????????????????????????????????????????????????????????????????????????????????????UT case??

????????????泻????????????????????????????????????????写?????????????????畏?????????“????????胁?????????????”??????????????????????????????????????????些?????纾�??????????????????????????????????????????????bug?????