[SpringBoot] 84. Various ways of handling exceptions in MVC in SpringBoot

In SpringBoot, we can use the annotations @ControllerAdvice and @RestControllerAdvice to handle exceptions globally. These two annotations only have one more annotation @ResponseBody, which writes the return value of the method to the body of the response in a specific format, and then returns the data For the client, if it is a string, output string information directly, if it is an object, it will convert the object into json for output

1. The internal processing exception of the controller

@RestController
public class TestController {
   
    
      
  @GetMapping("/test/{id}")
  public Object test(@

Guess you like

Origin blog.csdn.net/qq_40065776/article/details/131637937