当前位置: 首页>>代码示例>>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;未经允许,请勿转载。