import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 控制器全局异常处理
*
* @author pj.w@qq.com
*/
@ControllerAdvice
public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(Exception.class)
public Object globalExceptionHandler(Exception e) {
e.printStackTrace();
return e.getMessage();
}
@ResponseBody
@ExceptionHandler(MyE.class)
public Object globalExceptionHandler(MyE e) {
e.printStackTrace();
return e.getMessage();
}
}