当前位置: 首页>>代码示例>>Java>>正文


Java HttpRequestMethodNotSupportedException类代码示例

本文整理汇总了Java中org.springframework.web.HttpRequestMethodNotSupportedException的典型用法代码示例。如果您正苦于以下问题:Java HttpRequestMethodNotSupportedException类的具体用法?Java HttpRequestMethodNotSupportedException怎么用?Java HttpRequestMethodNotSupportedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpRequestMethodNotSupportedException类属于org.springframework.web包,在下文中一共展示了HttpRequestMethodNotSupportedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processMethodNotSupportedException

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
@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,代码行数:8,代码来源:ExceptionTranslator.java

示例2: handleHttpRequestMethodNotSupportedException

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
/**
 * 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,代码行数:12,代码来源:ExceptionAdvice.java

示例3: service

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException {

	LocaleContextHolder.setLocale(request.getLocale());
	try {
		this.target.handleRequest(request, response);
	}
	catch (HttpRequestMethodNotSupportedException ex) {
		String[] supportedMethods = ex.getSupportedMethods();
		if (supportedMethods != null) {
			response.setHeader("Allow", StringUtils.arrayToDelimitedString(supportedMethods, ", "));
		}
		response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, ex.getMessage());
	}
	finally {
		LocaleContextHolder.resetLocaleContext();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:HttpRequestHandlerServlet.java

示例4: handleRequest

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
/**
 * Processes the incoming Burlap request and creates a Burlap response.
 */
@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException {

	if (!"POST".equals(request.getMethod())) {
		throw new HttpRequestMethodNotSupportedException(request.getMethod(),
				new String[] {"POST"}, "BurlapServiceExporter only supports POST requests");
	}

	try {
	  invoke(request.getInputStream(), response.getOutputStream());
	}
	catch (Throwable ex) {
	  throw new NestedServletException("Burlap skeleton invocation failed", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:BurlapServiceExporter.java

示例5: handleRequest

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
/**
 * Processes the incoming Hessian request and creates a Hessian response.
 */
@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException {

	if (!"POST".equals(request.getMethod())) {
		throw new HttpRequestMethodNotSupportedException(request.getMethod(),
				new String[] {"POST"}, "HessianServiceExporter only supports POST requests");
	}

	response.setContentType(CONTENT_TYPE_HESSIAN);
	try {
	  invoke(request.getInputStream(), response.getOutputStream());
	}
	catch (Throwable ex) {
	  throw new NestedServletException("Hessian skeleton invocation failed", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:HessianServiceExporter.java

示例6: handleHttpRequestMethodNotSupportedException

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
/**
 * 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,代码行数:10,代码来源:GlobalHandler.java

示例7: resolveException

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
                                     Exception ex) {
    FResult<String> result = null;
    if (ex instanceof HttpRequestMethodNotSupportedException) {
        HttpRequestMethodNotSupportedException newExp = (HttpRequestMethodNotSupportedException) ex;
        result = FResult.newFailure(HttpResponseCode.CLIENT_PARAM_INVALID, newExp.getMessage());
    } else if (ex instanceof MaxUploadSizeExceededException) {
        result = FResult.newFailure(HttpResponseCode.CLIENT_PARAM_INVALID, "上传文件大小超出限制");
    } else if (ex instanceof SizeLimitExceededException) {
        result = FResult.newFailure(HttpResponseCode.CLIENT_PARAM_INVALID, "上传文件大小超出限制");
    } else {
        result = FResult.newFailure(HttpResponseCode.SERVER_ERROR, ex.getMessage());
    }
    ServletUtil.responseOutWithJson(response, result);
    return null;
}
 
开发者ID:devpage,项目名称:fastdfs-quickstart,代码行数:18,代码来源:ExceptionHandler.java

示例8: handleHttpRequestMethodNotSupportedException

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
@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,代码行数:12,代码来源:LocAdviceErrorAutoConfiguration.java

示例9: handleHttpRequestMethodNotSupported

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
@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,代码行数:13,代码来源:CustomRestExceptionHandler.java

示例10: handleHttpRequestMethodNotSupported

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
@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,代码行数:14,代码来源:GlobalErrorHandlers.java

示例11: handleHttpRequestMethodNotSupportedException

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
/**
 * 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,代码行数:10,代码来源:ExceptionAdvice.java

示例12: process

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
@Override
public void process(PluginContext ctx, PluginRestMsg msg) {
  try {
    log.debug("[{}] Processing REST msg: {}", ctx.getPluginId(), msg);
    HttpMethod method = msg.getRequest().getMethod();
    switch (method) {
    case GET:
      handleHttpGetRequest(ctx, msg);
      break;
    case POST:
      handleHttpPostRequest(ctx, msg);
      break;
    case DELETE:
      handleHttpDeleteRequest(ctx, msg);
      break;
    default:
      msg.getResponseHolder().setErrorResult(new HttpRequestMethodNotSupportedException(method.name()));
    }
    log.debug("[{}] Processed REST msg.", ctx.getPluginId());
  } catch (Exception e) {
    log.warn("[{}] Exception during REST msg processing: {}", ctx.getPluginId(), e.getMessage(), e);
    msg.getResponseHolder().setErrorResult(e);
  }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:25,代码来源:DefaultRestMsgHandler.java

示例13: validateMapping

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
/**
 * Validate the given type-level mapping metadata against the current request,
 * checking HTTP request method and parameter conditions.
 * @param mapping the mapping metadata to validate
 * @param request current HTTP request
 * @throws Exception if validation failed
 */
protected void validateMapping(RequestMapping mapping, HttpServletRequest request) throws Exception {
	RequestMethod[] mappedMethods = mapping.method();
	if (!ServletAnnotationMappingUtils.checkRequestMethod(mappedMethods, request)) {
		String[] supportedMethods = new String[mappedMethods.length];
		for (int i = 0; i < mappedMethods.length; i++) {
			supportedMethods[i] = mappedMethods[i].name();
		}
		throw new HttpRequestMethodNotSupportedException(request.getMethod(), supportedMethods);
	}

	String[] mappedParams = mapping.params();
	if (!ServletAnnotationMappingUtils.checkParameters(mappedParams, request)) {
		throw new UnsatisfiedServletRequestParameterException(mappedParams, request.getParameterMap());
	}

	String[] mappedHeaders = mapping.headers();
	if (!ServletAnnotationMappingUtils.checkHeaders(mappedHeaders, request)) {
		throw new ServletRequestBindingException("Header conditions \"" +
				StringUtils.arrayToDelimitedString(mappedHeaders, ", ") +
				"\" not met for actual request");
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:DefaultAnnotationHandlerMapping.java

示例14: handleHttpRequestMethodNotSupported

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
@Override
protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(final HttpRequestMethodNotSupportedException ex, final HttpHeaders headers,
        final HttpStatus status, final WebRequest request) {
    logger.info(ex.getClass().getName());
    //
    final ErrorDetail errorDetail = new ErrorDetail();
    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 + " "));

    errorDetail.setTimeStamp(new Date().getTime());
    errorDetail.setStatus(status.value());
    errorDetail.setTitle("Method not supported");
    errorDetail.setDetail(builder.toString());
    errorDetail.setDeveloperMessage(ex.getClass().getName());

    return handleExceptionInternal(ex, errorDetail, headers, status, request);
}
 
开发者ID:tvajjala,项目名称:interview-preparation,代码行数:20,代码来源:GlobalExceptionHandler.java

示例15: postContent

import org.springframework.web.HttpRequestMethodNotSupportedException; //导入依赖的package包/类
@StoreType("contentstore")
@RequestMapping(value = BASE_MAPPING, method = RequestMethod.POST, headers = "content-type!=multipart/form-data")
@ResponseBody
public ResponseEntity<Resource<?>> postContent(HttpServletRequest request,
		        							   HttpServletResponse response,
					        				   @PathVariable String repository, 
											   @PathVariable String id, 
											   @PathVariable String contentProperty) 
								throws IOException, HttpRequestMethodNotSupportedException, InstantiationException, IllegalAccessException {
	
	Object newContent = this.saveContentInternal(repositories, storeService, repository, id, contentProperty, request.getRequestURI(), request.getHeader("Content-Type"), request.getInputStream());
	if (newContent != null) {
		Resource<?> contentResource = toResource(request, newContent);
		return new ResponseEntity<Resource<?>>(contentResource, HttpStatus.CREATED);
	}
	return null;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:18,代码来源:ContentPropertyCollectionRestController.java


注:本文中的org.springframework.web.HttpRequestMethodNotSupportedException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。