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