/** * 405 - Method Not Allowed */ @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ExceptionHandler(HttpRequestMethodNotSupportedException.class) public AjaxResult handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { logger.error("不支持当前请求方法", e); return new AjaxResult().failure("request_method_not_supported"); }
@RequestMapping("/updateDynamicScheduledTask") @ResponseBody public AjaxResult updateDynamicScheduledTask() { dynamicScheduledTask.setCron("0/10 * * * * ?"); return new AjaxResult().success(); } }
@RequestMapping("/delete") @ResponseBody public AjaxResult delete(Long id) { int a = 1 / 0; userRepository.delete(id); return new AjaxResult().success(); } }
/** * 415 - Unsupported Media Type */ @ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE) @ExceptionHandler(HttpMediaTypeNotSupportedException.class) public AjaxResult handleHttpMediaTypeNotSupportedException(Exception e) { logger.error("不支持当前媒体类型", e); return new AjaxResult().failure("content_type_not_supported"); }
@RequestMapping("/save") @ResponseBody public AjaxResult save(User user) { userRepository.save(user); return new AjaxResult().success(); }
/** * 405 - Method Not Allowed */ @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ExceptionHandler(HttpRequestMethodNotSupportedException.class) public AjaxResult handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { logger.error("不支持当前请求方法", e); return new AjaxResult().failure("request_method_not_supported"); }
@RequestMapping("/save") @ResponseBody public AjaxResult save(User user) { userRepository.save(user); return new AjaxResult().success(); }
/** * 400 - Bad Request */ @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(MissingServletRequestParameterException.class) public AjaxResult handleMissingServletRequestParameterException(MissingServletRequestParameterException e) { logger.error("缺少请求参数", e); return new AjaxResult().failure("required_parameter_is_not_present"); }
@RequestMapping("/delete") @ResponseBody public AjaxResult delete(Long id) { int a = 1 / 0; userRepository.delete(id); return new AjaxResult().success(); } }
/** * 405 - Method Not Allowed */ @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ExceptionHandler(HttpRequestMethodNotSupportedException.class) public AjaxResult handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { logger.error("不支持当前请求方法", e); return new AjaxResult().failure("request_method_not_supported"); }
@RequestMapping("/delete") @ResponseBody public AjaxResult delete(Long id) { int a = 1 / 0; userRepository.delete(id); return new AjaxResult().success(); } }
/** * 400 - Bad Request */ @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(MissingServletRequestParameterException.class) public AjaxResult handleMissingServletRequestParameterException(MissingServletRequestParameterException e) { logger.error("缺少请求参数", e); return new AjaxResult().failure("required_parameter_is_not_present"); }
@RequestMapping("/delete") @ResponseBody public AjaxResult delete(Long id) { // int a = 1 / 0; userService.delete(id); return new AjaxResult().success(); } }
/** * 415 - Unsupported Media Type */ @ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE) @ExceptionHandler(HttpMediaTypeNotSupportedException.class) public AjaxResult handleHttpMediaTypeNotSupportedException(Exception e) { logger.error("不支持当前媒体类型", e); return new AjaxResult().failure("content_type_not_supported"); }
@RequestMapping("/delete") @ResponseBody public AjaxResult delete(Long id) { // int a = 1 / 0; userRepository.delete(id); return new AjaxResult().success(); }
/** * 400 - Bad Request */ @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(ValidationException.class) public AjaxResult handleValidationException(ValidationException e) { logger.error("参数验证失败", e); return new AjaxResult().failure("validation_exception"); }
@RequestMapping("/save") @ResponseBody public AjaxResult save(User user) { userRepository.save(user); return new AjaxResult().success(); }
/** * 操作数据库出现异常:名称重复,外键关联 */ @ResponseStatus(HttpStatus.OK) @ExceptionHandler(DataIntegrityViolationException.class) public AjaxResult handleException(DataIntegrityViolationException e) { logger.error("操作数据库出现异常:", e); return new AjaxResult().failure("操作数据库出现异常:字段重复、有外键关联等"); } }
@RequestMapping("/save") @ResponseBody public AjaxResult save(User user) { userRepository.save(user); return new AjaxResult().success(); }
/** * 400 - Bad Request */ @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(ValidationException.class) public AjaxResult handleValidationException(ValidationException e) { logger.error("参数验证失败", e); return new AjaxResult().failure("validation_exception"); }