當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpRequestMethodNotSupportedException.getSupportedHttpMethods方法代碼示例

本文整理匯總了Java中org.springframework.web.HttpRequestMethodNotSupportedException.getSupportedHttpMethods方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpRequestMethodNotSupportedException.getSupportedHttpMethods方法的具體用法?Java HttpRequestMethodNotSupportedException.getSupportedHttpMethods怎麽用?Java HttpRequestMethodNotSupportedException.getSupportedHttpMethods使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.HttpRequestMethodNotSupportedException的用法示例。


在下文中一共展示了HttpRequestMethodNotSupportedException.getSupportedHttpMethods方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleHttpRequestMethodNotSupported

import org.springframework.web.HttpRequestMethodNotSupportedException; //導入方法依賴的package包/類
/**
 * Customize the response for HttpRequestMethodNotSupportedException.
 * <p>This method logs a warning, sets the "Allow" header, and delegates to
 * {@link #handleExceptionInternal}.
 * @param ex the exception
 * @param headers the headers to be written to the response
 * @param status the selected response status
 * @param request the current request
 * @return a {@code ResponseEntity} instance
 */
protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex,
		HttpHeaders headers, HttpStatus status, WebRequest request) {

	pageNotFoundLogger.warn(ex.getMessage());

	Set<HttpMethod> supportedMethods = ex.getSupportedHttpMethods();
	if (!supportedMethods.isEmpty()) {
		headers.setAllow(supportedMethods);
	}

	return handleExceptionInternal(ex, null, headers, status, request);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:23,代碼來源:ResponseEntityExceptionHandler.java

示例2: handleHttpRequestMethodNotSupported

import org.springframework.web.HttpRequestMethodNotSupportedException; //導入方法依賴的package包/類
protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, HttpHeaders headers, HttpStatus status, HttpServletRequest request) {
    pageNotFoundLogger.warn(ex.getMessage());
    Set supportedMethods = ex.getSupportedHttpMethods();
    if(!supportedMethods.isEmpty()) {
        headers.setAllow(supportedMethods);
    }

    return handleExceptionInternal(ex, (Object) null, headers, status, request);
}
 
開發者ID:xmomen,項目名稱:easy-mybatis,代碼行數:10,代碼來源:RestExceptionHandler.java


注:本文中的org.springframework.web.HttpRequestMethodNotSupportedException.getSupportedHttpMethods方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。