@ControllerAdvice public class RunTimeExceptionHandler { //返回json格式 @ExceptionHandler(RuntimeException.class) @ResponseBody public Map<Object,Object> exceptionHandler(){ Map<Object,Object> result=new HashMap<>(); result.put("code",500); result.put("msg","系统错误"); return result; } /* //返回错误页面 @ExceptionHandler(RuntimeException.class) public String exceptionHandlerHtml(){ return "505"; } */ }
spring-boot 全局捕获异常
最新推荐文章于 2023-04-28 10:15:19 发布