捕捉异常,自定义返回
通过@ControllerAdvice()注解,当控制层发生异常,返回特定的json。
给出示例,对于com下面包的控制层出现异常,则捕捉
package com.research.common;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.WebRequest;
import