當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。