测试博客

发布时间 2023-07-10 11:45:40作者: 绿树荫下跑猫猫

SpringBoot学习记录

常见的问题

这是一篇测试markdown文件

  • 无敌是多么寂寞
  • 啊啊啊啊
  • 大无畏
  1. yes this
  2. 我也没不知u
package com.test.exception;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestControllerAdvice
public class GlobalExceptionHandler {
    //处理普通系统异常
    @ExceptionHandler(value = Exception.class)
    public R systemException(Exception e){
        e.printStackTrace();
        System.out.println("==================================>>"+e.getMessage()+"=================================");
        return new R(false,null,"系统内部异常,请联系管理员");
    }

    @ExceptionHandler(value = MyExceptionHandler.class)
    public ResponseEntity<R> myException(MyExceptionHandler e){
        e.printStackTrace();
        ResponseEntity<R> responseEntity;
        switch (e.getCode()){
            case 403:
                responseEntity =  ResponseEntity.status(HttpStatus.FORBIDDEN).body(new R(e.getMsg()));
                break;
            case 404:
                responseEntity =  ResponseEntity.status(HttpStatus.NOT_FOUND).body(new R(e.getMsg()));
                break;
            default:
                responseEntity =  ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new R(e.getMsg()));
                break;
        }

        return responseEntity;

    }
}

呜呜呜 沃达丰 安放在福娃发
111 222 33333
111 222 3333333333333
2222 44444 555555

\[5+6=x+2;h_\theta(x)=\theta_0+\theta_1x \]

屏幕截图 2023-06-18 092108