throw exception 3 ?
来源:13-12 完善登录注册校验功能

慕神4535282
2020-10-23
老师,下午好,请教一个问题,
@PostMapping("/reset-password")
public ResponseDto resetPassword(@RequestBody MemberDto memberDto) throws BusinessException { // 同样是调用会抛出错误的函数,为何这一行加不加上 throws BusinessException , 在IDEA中都不会报错
// 略
// 重置密码
memberService.resetPassword(memberDto);
}
public void resetPassword(MemberDto memberDto) throws BusinessException {
}
而
public void imageCode(@PathVariable(value = "imageCodeToken") String imageCodeToken, HttpServletRequest request, HttpServletResponse httpServletResponse) throws Exception { // 同样是调用会抛出错误的函数,为何这一行不加上 throws Exception , 在IDEA中就会报错
// 略
ImageIO.write(challenge, "jpg", jpegOutputStream);
}
谢谢老师解答!
写回答
1回答
-
同前面的问题,BusinessException继承自RuntimeException,所以自定义异常或是JDK自带异常,继承RuntimeException的,写或不写throws都可以
012020-10-26
相似问题