org.springframework.web.bind.annotation.RequestMethod.values()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(71)

本文整理了Java中org.springframework.web.bind.annotation.RequestMethod.values方法的一些代码示例,展示了RequestMethod.values的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RequestMethod.values方法的具体详情如下:
包路径:org.springframework.web.bind.annotation.RequestMethod
类名称:RequestMethod
方法名:values

RequestMethod.values介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Test
public void getMatchingConditionWithEmptyConditions() {
  RequestMethodsRequestCondition condition = new RequestMethodsRequestCondition();
  for (RequestMethod method : RequestMethod.values()) {
    if (method != OPTIONS) {
      HttpServletRequest request = new MockHttpServletRequest(method.name(), "");
      assertNotNull(condition.getMatchingCondition(request));
    }
  }
  testNoMatch(condition, OPTIONS);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void getMatchingConditionWithEmptyConditions() throws Exception {
  RequestMethodsRequestCondition condition = new RequestMethodsRequestCondition();
  for (RequestMethod method : RequestMethod.values()) {
    if (method != OPTIONS) {
      ServerWebExchange exchange = getExchange(method.name());
      assertNotNull(condition.getMatchingCondition(exchange));
    }
  }
  testNoMatch(condition, OPTIONS);
}

代码示例来源:origin: io.springfox/springfox-swagger-common

@Override
public void apply(OperationContext context) {
 Optional<ApiOperation> apiOperationAnnotation = context.findAnnotation(ApiOperation.class);
 if (apiOperationAnnotation.isPresent() && StringUtils.hasText(apiOperationAnnotation.get().httpMethod())) {
  String apiMethod = apiOperationAnnotation.get().httpMethod();
  try {
   RequestMethod.valueOf(apiMethod);
   context.operationBuilder().method(HttpMethod.valueOf(apiMethod));
  } catch (IllegalArgumentException e) {
   log.error("Invalid http method: " + apiMethod + "Valid ones are [" + RequestMethod.values() + "]", e);
  }
 }
}

代码示例来源:origin: yujunhao8831/spring-boot-start-current

private void apiHandle ( PermissionResourceForm form , PermissionResource resource ) {
  if ( Objects.equals( resource.getResourceType().getValue() , ResourceType.API.getValue() ) ) {
    final Set< String > methods = Stream.of( RequestMethod.values() )
                      .map( RequestMethod::name )
                      .collect( Collectors.toSet() );
    for ( String method : form.getResourceApiUriMethods() ) {
      AssertUtils.isTrue( ! methods.contains( method ) , "操作失败,resourceApiUriMethods格式不正确" );
    }
    resource.setResourceApiUriMethods(
        form.getResourceApiUriMethods()
          .parallelStream()
          .collect( Collectors.joining( "," ) )
    );
    // 接口类型处理
    // + 接口类型权限资源, 这两个字段不能为空 -> resourceApiUri  resourceApiUriMethods
    AssertUtils.isTrue(
        StringUtils.isBlank( resource.getResourceApiUri() ) ,
        "api类型权限资源,resourceApiUri字段不能为空"
    );
    AssertUtils.isTrue(
        StringUtils.isBlank( resource.getResourceApiUriMethods() ) ,
        "api类型权限资源,resourceApiUriMethods字段不能为空"
    );
  }
}

代码示例来源:origin: com.github.wnameless.spring/spring-routing-resolver

for (RequestMethod m : RequestMethod.values()) {
 rawPathsAndMethods.add(Maps.immutableEntry(
   PathUtils.joinPaths(prefixPath, suffixPath), m));

代码示例来源:origin: com.github.springdox/springdox-swagger-common

@Override
public void apply(OperationContext context) {
 HandlerMethod handlerMethod = context.getHandlerMethod();
 ApiOperation apiOperationAnnotation = handlerMethod.getMethodAnnotation(ApiOperation.class);
 if (apiOperationAnnotation != null && StringUtils.hasText(apiOperationAnnotation.httpMethod())) {
  String apiMethod = apiOperationAnnotation.httpMethod();
  try {
   RequestMethod.valueOf(apiMethod);
   context.operationBuilder().method(apiMethod);
  } catch (IllegalArgumentException e) {
   log.error("Invalid http method: " + apiMethod + "Valid ones are [" + RequestMethod.values() + "]", e);
  }
 }
}

代码示例来源:origin: com.mangofactory/swagger-springmvc

@Override
 public void execute(RequestMappingContext context) {
  RequestMethod currentHttpMethod = (RequestMethod) context.get("currentHttpMethod");
  HandlerMethod handlerMethod = context.getHandlerMethod();

  String requestMethod = currentHttpMethod.toString();
  ApiOperation apiOperationAnnotation = handlerMethod.getMethodAnnotation(ApiOperation.class);

  if (apiOperationAnnotation != null && StringUtils.hasText(apiOperationAnnotation.httpMethod())) {
   String apiMethod = apiOperationAnnotation.httpMethod();
   try {
    RequestMethod.valueOf(apiMethod);
    requestMethod = apiMethod;
   } catch (IllegalArgumentException e) {
    log.error("Invalid http method: " + apiMethod + "Valid ones are [" + RequestMethod.values() + "]", e);
   }
  }
  context.put("httpRequestMethod", requestMethod);
 }
}

相关文章