package com.my.server2.config;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.jws.WebResult;
@ControllerAdvice
public class GlobalException {
@ExceptionHandler(Exception.class)
@ResponseBody
public String exceptionHandler(Exception e){
e.printStackTrace();
return "执行了全局异常处理";
}
}
一个类解决全局异常处理(最方便的一种解决方式)
最新推荐文章于 2024-06-13 08:37:22 发布