标签:frame code util stc 异常 erro map cep handler
使用 @ControllerAdvice
声明并用 @ExceptionHandler
声明需要捕获的异常。
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
@RestController
@ControllerAdvice
public class GlobalControllerExceptionHandler {
@ExceptionHandler(value = Exception.class)
public Map defaultErrorHandler(HttpServletRequest request, HttpServletResponse response, Exception e) {
// 省略部分代码
}
}
标签:frame code util stc 异常 erro map cep handler
原文地址:https://www.cnblogs.com/StarUDream/p/9045539.html