Spring-boot Return value

When the field is empty return

1. no return

  Local class configuration

@JsonInclude (JsonInclude.Include.NON_NULL) / * empty * does not return / 

Global
 spring:
  jackson:
  default-property-inclusion: non_null

2. asked to return to the state change, return a custom status code

@ResposneStatus(HttpStatus.FORBIDDEN)

 

3. unified exception handling (xx is a custom exception class)

@Exceptionhandle(xx.class)

 

Guess you like

Origin www.cnblogs.com/JTrun/p/11100473.html