当前位置: 首页>>代码示例>>Java>>正文


Java HttpStatus.METHOD_NOT_ALLOWED属性代码示例

本文整理汇总了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);
	}

}
 
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:26,代码来源:EnvironmentService.java

示例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);
}
 
开发者ID:WinstonZheng,项目名称:wtem,代码行数:9,代码来源:ExceptionAdvice.java

示例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());
}
 
开发者ID:lord-of-code,项目名称:loc-framework,代码行数:11,代码来源:LocAdviceErrorAutoConfiguration.java

示例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));
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:7,代码来源:ExceptionTranslator.java

示例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);
}
 
开发者ID:MasonQAQ,项目名称:WeatherSystem,代码行数:11,代码来源:ExceptionAdvice.java

示例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();
}
 
开发者ID:rozidan,项目名称:project-template,代码行数:13,代码来源:GlobalErrorHandlers.java

示例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());
}
 
开发者ID:junneyang,项目名称:xxproject,代码行数:12,代码来源:CustomRestExceptionHandler.java

示例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");
}
 
开发者ID:helloworldtang,项目名称:spring-boot-jwt-jpa,代码行数:9,代码来源:GlobalHandler.java

示例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());
}
 
开发者ID:Microsoft,项目名称:MTC_Labrat,代码行数:6,代码来源:ExceptionTranslator.java

示例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());
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:6,代码来源:ExceptionTranslator.java

示例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());
}
 
开发者ID:eclipse,项目名称:keti,代码行数:6,代码来源:HttpRequestMethodNotSupportedExceptionHandler.java


注:本文中的org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。