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

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

異常沒被捕獲呀。。。

我按課程代碼寫的異常沒被捕獲,什么情況? package handler; import com.imooc.domain.Result; import com.imooc.utils.ResultUtil; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; /** * Created by MBENBEN on 2017/6/18. */ @ControllerAdvice public class ExceptionHandle { ? ?@ExceptionHandler(value = Exception.class) ? ?@ResponseBody ? ?public Result handle(Exception e){ ? ? ? ? ?return ResultUtil.error(100,e.getMessage()); ? ?} } service里 public void getAge(Integer id) throws Exception{ ? ? ? ? Girl girl= girlRepository.findOne(id); ? ? ? ?Integer age=girl.getAge(); ? ? ? ?if(age<10){ throw="" new="" else="" age="">10 && age<16){ ? ? ? ? ? ?//你可能還在上初中 ? ? ? ? ? ?throw new Exception("你可能還在上初中"); ? ? ? ?} ? ? ? ?//如果大于16歲 ? ?} controller里 @GetMapping(value = "girls/getAge/{id}") ? ?public void getAge(@PathVariable("id") Integer id) throws Exception{ ? ? ? ?girlService.getAge(id); ? ?}

正在回答

4 回答

感謝感謝哈哈哈哈

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

謝謝老鐵

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

感謝了,老鐵

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

后來發(fā)現(xiàn)問題了,代碼都是正確的,注意handle包必須和controller包和service包在同一級包下才行!!

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

舉報(bào)

0/150
提交
取消

異常沒被捕獲呀。。。

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

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

幫助反饋 APP下載

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

公眾號(hào)

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