@ExceptionHandler(RuntimeException.class)咋没生效呢
Topic source楼上的老哥,有没有在signin失败的时候抛出runtime exception?
顺着廖老师的教程做过来的话之前是return new ModelAndView的 得注掉那句然后把e给丢出去才行
@PostMapping("/signin") public ModelAndView doSignin(@RequestParam("email") String email, @RequestParam("password") String password, HttpSession session) { try { User user = userService.signin(email, password); session.setAttribute(KEY_USER, user); } catch (RuntimeException e) {// return new ModelAndView("signin.html", Map.of("email", email, "error", "Signin failed")); throw e; } return new ModelAndView("redirect:/profile"); }
- 1
Defias-迪
异常处理器@ExceptionHandler(RuntimeException.class)没生效,密码错误时直接报错了,没有返回500的页面