本文整理匯總了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);
}
示例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);
}