第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

完全復(fù)制老師代碼,利用postman刪除一條數(shù)據(jù)時,拋出異常 空針,直接忽略還是需要處理?

完全復(fù)制老師代碼,利用postman刪除一條數(shù)據(jù)時,拋出異常 空針,直接忽略還是需要處理?

java.lang.NullpointerException:null???? 請問需要如何處理?

正在回答

5 回答

@DeleteMapping("/luckymoneys/{id}")
public?Result?deleteById(@PathVariable?Integer?id){
????service.delete(id);
???return??ResultUtil.success(null);

}
public?void?delete(Integer?id)?{
????Luckymoney?luckymoney?=?new?Luckymoney();
????luckymoney.setId(id);

????repository.delete(luckymoney);
}
@Pointcut("execution(public?*?com.imooc.luckymoney.controller.LuckMoneyController.*(..))?&&?!execution(public?*?com.imooc.luckymoney.controller.LuckMoneyController.delete*(..))"?)
public?void?log()?{

}

把delete從切入表達(dá)式中去除。或者新定義一個切入表達(dá)式,讓delete方法使用該切入點↓

@Pointcut("execution(public?*?com.imooc.luckymoney.controller.LuckMoneyController.*(..))?&&?!execution(public?*?com.imooc.luckymoney.controller.LuckMoneyController.delete*(..))"?)
public?void?logByDel(){

}


0 回復(fù) 有任何疑惑可以回復(fù)我~
@DeleteMapping("/girls/{id}")
public?void?girlDelete(@PathVariable("id")?Integer?id){
????????girlRepository.deleteById(id);
????throw?new?GirlException(ResultEnum.SUCCESS);
}

無返回值的加個

throw?new?GirlException(ResultEnum.SUCCESS);

就餓可以了

1 回復(fù) 有任何疑惑可以回復(fù)我~
應(yīng)該是deleteGirl方法沒有返回值,所以(@AfterReturning(returning?=?"object",pointcut?=?"log()"))doAftereReturning方法中參數(shù)Object為null,然后toString報的空指針吧


1 回復(fù) 有任何疑惑可以回復(fù)我~

我的也會出現(xiàn)這種情況,能成功刪除數(shù)據(jù),但是會報空指針錯誤!

0 回復(fù) 有任何疑惑可以回復(fù)我~

數(shù)據(jù)庫沒數(shù)據(jù)吧

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

soicano 提問者

你好,數(shù)據(jù)庫有數(shù)據(jù)的!無論用 Get還是Delete過去請求,進(jìn)行deletebyid對當(dāng)前實施刪除后!報異常!請問如何處理?哪怕刪除第一條或者最后一條任意一位置都拋出空針錯誤,當(dāng)然數(shù)據(jù)是刪除的,返回的時候執(zhí)行@after 拋出異常
2018-05-16 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

完全復(fù)制老師代碼,利用postman刪除一條數(shù)據(jù)時,拋出異常 空針,直接忽略還是需要處理?

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號