Codota Logo
RequestMethod
Code IndexAdd Codota to your IDE (free)

How to use
RequestMethod
in
org.springframework.web.bind.annotation

Best Java code snippets using org.springframework.web.bind.annotation.RequestMethod (Showing top 20 results out of 909)

  • Common ways to obtain RequestMethod
private void myMethod () {
RequestMethod r =
  • Codota IconString str;RequestMethod.valueOf(str)
  • Codota IconHttpServletRequest httpServletRequest;RequestMethod.valueOf(httpServletRequest.getMethod())
  • Smart code suggestions by Codota
}
origin: gocd/gocd

private boolean isReadOnlyRequest(HttpServletRequest servletRequest) {
  return RequestMethod.GET.name().equalsIgnoreCase(servletRequest.getMethod()) ||
      RequestMethod.HEAD.name().equalsIgnoreCase(servletRequest.getMethod());
}
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: top.wboost/common-web

@Override
public boolean supportsParameter(MethodParameter parameter) {
  if (parameter.getGenericParameterType() != java.lang.String.class) {
    return false;
  }
  RequestMapping requestMapping = parameter.getMethod().getAnnotation(RequestMapping.class);
  if (requestMapping != null) {
    RequestMethod[] rms = requestMapping.method();
    if (rms != null) {
      for (RequestMethod rm : rms) {
        if (rm.name().equals(RequestMethod.GET.toString())) {
          return true;
        }
      }
    }
  }
  return false;
}
origin: spring-projects/spring-hateoas

/**
 * Extract {@link org.springframework.web.bind.annotation.RequestMapping}'s list of {@link RequestMethod}s into an
 * array of {@link String}s.
 * 
 * @param type
 * @param method
 * @return
 */
@Override
public Collection<HttpMethod> getRequestMethod(Class<?> type, Method method) {
  Assert.notNull(type, "Type must not be null!");
  Assert.notNull(method, "Method must not be null!");
  Annotation mergedAnnotation = findMergedAnnotation(method, annotationType);
  Object value = getValue(mergedAnnotation, "method");
  RequestMethod[] requestMethods = (RequestMethod[]) value;
  List<HttpMethod> requestMethodNames = new ArrayList<>();
  for (RequestMethod requestMethod : requestMethods) {
    requestMethodNames.add(HttpMethod.valueOf(requestMethod.toString()));
  }
  return requestMethodNames;
}
origin: spring-projects/spring-integration

public RequestMethod[] getRequestMethods() {
  RequestMethod[] requestMethods = new RequestMethod[this.methods.length];
  for (int i = 0; i < this.methods.length; i++) {
    requestMethods[i] = RequestMethod.valueOf(this.methods[i].name());
  }
  return requestMethods;
}
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);
 }
}
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: foxinmy/weixin4j

if (request.getMethod().equalsIgnoreCase(RequestMethod.GET.toString())) {
  return doGet(weixinRequest);
} else if (request.getMethod().equalsIgnoreCase(RequestMethod.POST.toString())) {
  return doPost(weixinRequest);
} else {
origin: org.springframework.boot/spring-boot-actuator

private RequestMappingInfo createRequestMappingInfo(WebOperation operation) {
  WebOperationRequestPredicate predicate = operation.getRequestPredicate();
  PatternsRequestCondition patterns = patternsRequestConditionForPattern(
      predicate.getPath());
  RequestMethodsRequestCondition methods = new RequestMethodsRequestCondition(
      RequestMethod.valueOf(predicate.getHttpMethod().name()));
  ConsumesRequestCondition consumes = new ConsumesRequestCondition(
      StringUtils.toStringArray(predicate.getConsumes()));
  ProducesRequestCondition produces = new ProducesRequestCondition(
      StringUtils.toStringArray(predicate.getProduces()));
  return new RequestMappingInfo(null, patterns, methods, null, null, consumes,
      produces, null);
}
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: spring-projects/spring-framework

/**
 * Return declared HTTP methods.
 */
public Set<HttpMethod> getAllowedMethods() {
  return this.partialMatches.stream().
      flatMap(m -> m.getInfo().getMethodsCondition().getMethods().stream()).
      map(requestMethod -> HttpMethod.resolve(requestMethod.name())).
      collect(Collectors.toSet());
}
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: com.github.springdox/springdox-spi

public String httpMethod() {
 return requestMethod.toString();
}
origin: org.locationtech.geogig/geogig-web-api

@Override
public RequestMethod getMethod() {
  return RequestMethod.valueOf(request.getMethod());
}
origin: spring-projects/spring-framework

/**
 * Return declared HTTP methods.
 */
public Set<String> getAllowedMethods() {
  Set<String> result = new LinkedHashSet<>();
  for (PartialMatch match : this.partialMatches) {
    for (RequestMethod method : match.getInfo().getMethodsCondition().getMethods()) {
      result.add(method.name());
    }
  }
  return result;
}
origin: kongchen/swagger-maven-plugin

String httpMethod = requestMethod.toString().toLowerCase();
Operation operation = parseMethod(method, requestMethod);
origin: org.springframework.boot/spring-boot-actuator

private RequestMappingInfo createRequestMappingInfo(WebOperation operation) {
  WebOperationRequestPredicate predicate = operation.getRequestPredicate();
  PatternsRequestCondition patterns = new PatternsRequestCondition(pathPatternParser
      .parse(this.endpointMapping.createSubPath(predicate.getPath())));
  RequestMethodsRequestCondition methods = new RequestMethodsRequestCondition(
      RequestMethod.valueOf(predicate.getHttpMethod().name()));
  ConsumesRequestCondition consumes = new ConsumesRequestCondition(
      StringUtils.toStringArray(predicate.getConsumes()));
  ProducesRequestCondition produces = new ProducesRequestCondition(
      StringUtils.toStringArray(predicate.getProduces()));
  return new RequestMappingInfo(null, patterns, methods, null, null, consumes,
      produces, null);
}
origin: spring-projects/spring-framework

@Nullable
private RequestMethodsRequestCondition matchRequestMethod(@Nullable HttpMethod httpMethod) {
  if (httpMethod != null) {
    for (RequestMethod method : getMethods()) {
      if (httpMethod.matches(method.name())) {
        return new RequestMethodsRequestCondition(method);
      }
    }
    if (httpMethod == HttpMethod.HEAD && getMethods().contains(RequestMethod.GET)) {
      return GET_CONDITION;
    }
  }
  return null;
}
origin: org.locationtech.geogig/geogig-web-api

@RequestMapping(method = { PUT, DELETE, PATCH, TRACE, OPTIONS })
public void catchAll() {
  // if we hit this controller, it's a 405
  supportedMethods(Sets.newHashSet(GET.toString(), POST.toString()));
}
org.springframework.web.bind.annotationRequestMethod

Javadoc

Java 5 enumeration of HTTP request methods. Intended for use with the RequestMapping#method() attribute of the RequestMapping annotation.

Note that, by default, org.springframework.web.servlet.DispatcherServletsupports GET, HEAD, POST, PUT, PATCH and DELETE only. DispatcherServlet will process TRACE and OPTIONS with the default HttpServlet behavior unless explicitly told to dispatch those request types as well: Check out the "dispatchOptionsRequest" and "dispatchTraceRequest" properties, switching them to "true" if necessary.

Most used methods

  • name
  • toString
  • valueOf
  • values
  • equals
  • hashCode
  • compareTo

Popular in Java

  • Creating JSON documents from java classes using gson
  • getContentResolver (Context)
  • setScale (BigDecimal)
  • setContentView (Activity)
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Reference (javax.naming)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now