constroller异常统一处理类
其中result是想要返回的处理结果,博客目的是说明@controllerAdvice的扩展结合异常类使用
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@ControllerAdvice
public class BaseExceptionHander {
@ExceptionHandler(value = Exception.class)
@ResponseBody
public Result error(Exception e){
e.printStackTrace();
return new Result();
}
}