本文整理汇总了Java中org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.METHOD_NOT_ALLOWED属性的具体用法?Java HttpStatus.METHOD_NOT_ALLOWED怎么用?Java HttpStatus.METHOD_NOT_ALLOWED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.METHOD_NOT_ALLOWED属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getActuatorVersion
public ActuatorVersion getActuatorVersion(Application app) {
String url = app.endpoints().env();
try {
LOGGER.debug("HEAD {}", url);
HttpHeaders headers = headRestTemplate.headForHeaders(new URI(url));
return ActuatorVersion.parse(headers.getContentType());
} catch (RestClientException ex) {
if(ex instanceof HttpClientErrorException) {
HttpClientErrorException clientEx = ((HttpClientErrorException)ex);
// Spring Boot 1.3 does not allow HEAD method, so let's assume the app is up
if(clientEx.getStatusCode() == HttpStatus.METHOD_NOT_ALLOWED) {
return ActuatorVersion.V1;
}
}
throw RestTemplateErrorHandler.handle(app, url, ex);
} catch (URISyntaxException e) {
throw RestTemplateErrorHandler.handle(app, e);
}
}
示例2: handleHttpRequestMethodNotSupportedException
/**
* 405 - Method Not Allowed
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Response handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
logger.error("不支持当前请求方法", e);
return new Response().failure(ReturnStatus.METHOD_NOT_ALLOWED);
}
示例3: handleHttpRequestMethodNotSupportedException
@ResponseStatus(value = HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
//对于接口方法不匹配的异常处理
public BasicResult handleHttpRequestMethodNotSupportedException(
HttpRequestMethodNotSupportedException e) {
logError("httpRequestMethodNotSupportedException", e.getMessage(), e);
return BasicResult
.fail(BasicResultCode.METHOD_NOT_ALLOW_ERROR.getCode(),
BasicResultCode.METHOD_NOT_ALLOW_ERROR.getMsg(),
e.getMessage());
}
示例4: processMethodNotSupportedException
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@ResponseBody
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) {
log.debug("Method not supported", exception);
return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, translate(ErrorConstants.ERR_METHOD_NOT_SUPPORTED));
}
示例5: handleHttpRequestMethodNotSupportedException
/**
* 405 - Method Not Allowed
* @param e
* @return
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public ReturnPureNotifyApi handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
logger.error("[METHOD NOT ALLOWED] " + e.getMessage());
return new ReturnPureNotifyApi(ApiStatus.METHOD_NOT_ALLOWED);
}
示例6: handleHttpRequestMethodNotSupported
@Loggable
@ResponseStatus(code = HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public ErrorDto handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex) {
return ErrorDto.builder()
.errorCode(ErrorCodes.METHOD_NOT_ALLOWED)
.errors(Collections.singleton(HttpRequestMethodErrorDto.builder()
.actualMethod(ex.getMethod())
.supportedMethods(ex.getSupportedHttpMethods())
.build()))
.message(ex.getLocalizedMessage())
.build();
}
示例7: handleHttpRequestMethodNotSupported
@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());
}
示例8: handleHttpRequestMethodNotSupportedException
/**
* 405 - Method Not Allowed
*/
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public ResponseEntity handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
LOGGER.error("不支持当前请求方法", e);
return ResponseEntity.badRequest().body("request_method_not_supported");
}
示例9: processMethodNotSupportedException
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@ResponseBody
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public ErrorVM processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) {
return new ErrorVM(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage());
}
示例10: processMethodNotSupportedException
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@ResponseBody
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public ErrorDTO processMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) {
return new ErrorDTO(ErrorConstants.ERR_METHOD_NOT_SUPPORTED, exception.getMessage());
}
示例11: handleException
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
@ResponseBody
public RestApiErrorResponse handleException(final HttpRequestMethodNotSupportedException e) {
return super.handleException(e, HttpStatus.METHOD_NOT_ALLOWED.getReasonPhrase());
}