@RequestMapping("saveCustInfo")
@ResponseBody
public Map<String,String> saveCustomerInfo(Customer customer){
try {
customerService.savaNewCustomerInfo(customer);
} catch (Exception e) {
log.error(e.getMessage());
}
//以下代码在有异常情况下仍然会执行
Map<String,String> resMap = new HashMap<String,String>();
resMap.put("resFlag", "Y");
return resMap;
}
@RequestMapping("saveCustInfo")
@ResponseBody
public Map<String,String> saveCustomerInfo(Customer customer){
Map<String,String> resMap = new HashMap<String,String>();
try {
customerService.savaNewCustomerInfo(customer);
resMap.put("resFlag", "Y");//此处代码在有异常情况下不会执行
} catch (Exception e) {
resMap.put("resFlag", "N");//此处代码在有异常情况下才会执行
log.error(e.getMessage());
}
return resMap;
}
异常情况下代码执行的先后顺序
最新推荐文章于 2021-12-30 09:20:51 发布