- 实体或者值对象的field加@xxx
- 方法入口参数加@Valid注解
- 自定义的注解需实现ConstraintValidator<IsPhoneNumber, String>接口
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {
@ExceptionHandler(value = Exception.class)
@Component
public class LoginRequiredInterceptor implements HandlerInterceptor {
@Component
public class ToutiaoWebConfiguration extends WebMvcConfigurer{
@Override
public void addInterceptors(InterceptorRegistry registry) {
@Service
public class UserArgumentResolver implements HandlerMethodArgumentResolver {
}
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers){