创建一个异常处理器 作为springMVC的异常处理器

    1. // 作为springMVC的异常处理器
    2. //@ControllerAdvice // 可选
    3. @RestControllerAdvice // 里面带了 @ResponeBody
    4. public class ProjectExceptionAdvice {
    5. // 拦截所有的异常信息
    6. @ExceptionHandler
    7. public Result doException(Exception e) {
    8. // return的数据会传递给客户端
    9. return new Result();
    10. }
    11. }