版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32352825/article/details/79279493
引用块内容
/**
* spring boot 捕获异常-----捕获全局异常信息,统一返回给前台的数据格式
* Created by yangchen on 2018/2/7
*/
@ControllerAdvice
public class ExceptionHandler {
@org.springframework.web.bind.annotation.ExceptionHandler(value = Exception.class)
@ResponseBody
public Object handler(Exception e){
return ResultUtils.build(500,e.getMessage());
}
}