Java Code Examples for org.springframework.http.HttpStatus#METHOD_NOT_ALLOWED
The following examples show how to use
org.springframework.http.HttpStatus#METHOD_NOT_ALLOWED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestControllerExceptionTranslator.java From hsweb-framework with Apache License 2.0 | 5 votes |
/** * 请求方式不支持异常 * 比如:POST方式的API, GET方式请求 */ @ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) ResponseMessage handleException(HttpRequestMethodNotSupportedException exception) { return ResponseMessage .error(HttpStatus.METHOD_NOT_ALLOWED.value(), "不支持的请求方式") .result(exception.getSupportedHttpMethods()); }
Example 2
Source File: DefaultExceptionAdvice.java From Taroco with Apache License 2.0 | 5 votes |
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ExceptionHandler({HttpRequestMethodNotSupportedException.class}) public ResponseEntity handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { LOGGER.error("不支持当前请求方法", e); Response response = Response.failure(DefaultError.METHOD_NOT_SUPPORTED); response.setExtMessage(e.getMessage()); return new ResponseEntity<>(response, HttpStatus.METHOD_NOT_ALLOWED); }
Example 3
Source File: HerdErrorInformationExceptionHandler.java From herd with Apache License 2.0 | 5 votes |
/** * Handle exceptions that result in a "operation not allowed" status. */ @ExceptionHandler(value = MethodNotAllowedException.class) @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ResponseBody public ErrorInformation handleOperationNotAllowedException(RuntimeException exception) { return getErrorInformation(HttpStatus.METHOD_NOT_ALLOWED, exception); }
Example 4
Source File: ExceptionAdvice.java From EasyReport with Apache License 2.0 | 5 votes |
/** * 405 - Method Not Allowed */ @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ExceptionHandler(HttpRequestMethodNotSupportedException.class) public ResponseResult handleHttpRequestMethodNotSupportedException(final HttpRequestMethodNotSupportedException e) { log.error(HttpStatus.METHOD_NOT_ALLOWED.getReasonPhrase(), e); return ResponseResult.failure(SystemErrorCode.METHOD_NOT_ALLOWED, e); }
Example 5
Source File: CustomRestExceptionHandler.java From tutorials with MIT License | 5 votes |
@Override protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(final HttpRequestMethodNotSupportedException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { logger.info(ex.getClass().getName()); // final StringBuilder builder = new StringBuilder(); builder.append(ex.getMethod()); builder.append(" method is not supported for this request. Supported methods are "); ex.getSupportedHttpMethods().forEach(t -> builder.append(t + " ")); final ApiError apiError = new ApiError(HttpStatus.METHOD_NOT_ALLOWED, ex.getLocalizedMessage(), builder.toString()); return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus()); }
Example 6
Source File: CustomRestExceptionHandler.java From xxproject with Apache License 2.0 | 5 votes |
@Override protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(final HttpRequestMethodNotSupportedException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { logger.info(ex.getClass().getName()); // final StringBuilder builder = new StringBuilder(); builder.append(ex.getMethod()); builder.append(" method is not supported for this request. Supported methods are "); ex.getSupportedHttpMethods().forEach(t -> builder.append(t + " ")); final ApiError apiError = new ApiError(HttpStatus.METHOD_NOT_ALLOWED, ex.getLocalizedMessage(), builder.toString()); return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus()); }
Example 7
Source File: ExceptionTranslator.java From tutorials with MIT License | 4 votes |
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseBody @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) { return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage()); }
Example 8
Source File: ExceptionTranslator.java From klask-io with GNU General Public License v3.0 | 4 votes |
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseBody @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public ErrorDTO processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) { return new ErrorDTO(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage()); }
Example 9
Source File: WebRestControllerAdvice.java From cloud-transfer-backend with MIT License | 4 votes |
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) public ResponseEntity<ApiError> handleMethodNotSupportedException(HttpRequestMethodNotSupportedException ex) { ApiError apiError = new ApiError(HttpStatus.METHOD_NOT_ALLOWED, ex.getMessage(), null); return new ResponseEntity<>(apiError, apiError.getStatus()); }
Example 10
Source File: ExceptionTranslator.java From tutorials with MIT License | 4 votes |
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseBody @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) { return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage()); }
Example 11
Source File: ExceptionTranslator.java From jhipster-microservices-example with Apache License 2.0 | 4 votes |
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseBody @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) { return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage()); }
Example 12
Source File: ExceptionTranslator.java From flair-engine with Apache License 2.0 | 4 votes |
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseBody @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) { return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage()); }
Example 13
Source File: ExceptionTranslator.java From flair-registry with Apache License 2.0 | 4 votes |
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseBody @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) { return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage()); }
Example 14
Source File: AuthenticationController.java From cf-SpringBootTrader with Apache License 2.0 | 4 votes |
/** * To ensure no one does login through HTTP GET. * returns METHOD_NOT_ALLOWED. */ @RequestMapping(value = "/login", method = RequestMethod.GET) @ResponseStatus( HttpStatus.METHOD_NOT_ALLOWED ) public void get() { }
Example 15
Source File: BladeRestExceptionTranslator.java From blade-tool with GNU Lesser General Public License v3.0 | 4 votes |
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public R handleError(HttpRequestMethodNotSupportedException e) { log.error("不支持当前请求方法:{}", e.getMessage()); return R.fail(ResultCode.METHOD_NOT_SUPPORTED, e.getMessage()); }
Example 16
Source File: CenterApi.java From MicroCommunity with Apache License 2.0 | 4 votes |
/** * * @param request HttpServletRequest对象 * @return */ @RequestMapping(path = "/service",method= RequestMethod.DELETE) @ApiOperation(value="中心服务delete方式请求", notes="test: 返回 502 表示服务不支持DELETE 请求方式") public ResponseEntity<String> serviceDelete(HttpServletRequest request) { return new ResponseEntity<String>("center服务 不支持GET 请求方式", HttpStatus.METHOD_NOT_ALLOWED); }
Example 17
Source File: ExceptionTranslator.java From jhipster-microservices-example with Apache License 2.0 | 4 votes |
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseBody @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) { return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage()); }
Example 18
Source File: GlobalExceptionHandler.java From find with MIT License | 4 votes |
@ExceptionHandler(HttpRequestMethodNotSupportedException.class) @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ResponseBody public ErrorResponse requestMethodNotSupportedHandler(final HttpRequestMethodNotSupportedException exception) throws HttpRequestMethodNotSupportedException { return handler(exception); }
Example 19
Source File: TaxPaymentWebServiceTest.java From batchers with Apache License 2.0 | 4 votes |
private HttpClientErrorException aMethodNotAllowedException() { return new HttpClientErrorException(HttpStatus.METHOD_NOT_ALLOWED); }
Example 20
Source File: GlobalExceptionHandler.java From SuperBoot with MIT License | 2 votes |
/** * 不支持当前请求方法 * * @param e 异常信息 * @return */ @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED) @ExceptionHandler(HttpRequestMethodNotSupportedException.class) public BaseMessage handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { return pubTools.genNoMsg(StatusCode.METHOD_NOT_ALLOWED, e.getMessage()); }