本文整理了Java中org.springframework.web.bind.annotation.RequestMethod.valueOf
方法的一些代码示例,展示了RequestMethod.valueOf
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RequestMethod.valueOf
方法的具体详情如下:
包路径:org.springframework.web.bind.annotation.RequestMethod
类名称:RequestMethod
方法名:valueOf
暂无
代码示例来源: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: org.locationtech.geogig/geogig-web-api
@Override
public RequestMethod getMethod() {
return RequestMethod.valueOf(request.getMethod());
}
代码示例来源: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: 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: com.github.springdox/springdox-spi
public List<ResponseMessage> getGlobalResponseMessages(String forHttpMethod) {
if (documentationContext.getGlobalResponseMessages().containsKey(RequestMethod.valueOf(forHttpMethod))) {
return documentationContext.getGlobalResponseMessages().get(RequestMethod.valueOf(forHttpMethod));
}
return newArrayList();
}
代码示例来源:origin: org.springframework.integration/spring-integration-http
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: spring-projects/spring-batch-admin
private List<ResourceInfo> buildResourcesFromProperties(Properties properties, Properties defaults) {
Set<ResourceInfo> resources = new TreeSet<ResourceInfo>();
if (properties == null) {
if (defaults == null) {
return new ArrayList<ResourceInfo>();
}
properties = defaults;
}
for (Enumeration<?> iterator = properties.propertyNames(); iterator.hasMoreElements();) {
String key = (String) iterator.nextElement();
String method = key.substring(0, key.indexOf("/"));
String url = key.substring(key.indexOf("/"));
String description = properties.getProperty(key, defaults.getProperty(key));
resources.add(new ResourceInfo(url, RequestMethod.valueOf(method), description));
}
return new ArrayList<ResourceInfo>(resources);
}
代码示例来源:origin: org.springframework.batch/spring-batch-admin-resources
private List<ResourceInfo> buildResourcesFromProperties(Properties properties, Properties defaults) {
Set<ResourceInfo> resources = new TreeSet<ResourceInfo>();
if (properties == null) {
if (defaults == null) {
return new ArrayList<ResourceInfo>();
}
properties = defaults;
}
for (Enumeration<?> iterator = properties.propertyNames(); iterator.hasMoreElements();) {
String key = (String) iterator.nextElement();
String method = key.substring(0, key.indexOf("/"));
String url = key.substring(key.indexOf("/"));
String description = properties.getProperty(key, defaults.getProperty(key));
resources.add(new ResourceInfo(url, RequestMethod.valueOf(method), description));
}
return new ArrayList<ResourceInfo>(resources);
}
代码示例来源:origin: cn.home1/oss-lib-errorhandle-spring-boot-1.4.1.RELEASE
@Override
protected void doFilterInternal( //
final HttpServletRequest request, //
final HttpServletResponse response, //
final FilterChain filterChain //
) throws ServletException, IOException {
final RequestMethod requestMethod = RequestMethod.valueOf(request.getMethod());
final String contentType = request.getContentType();
final Boolean interested = requestMethod != GET && requestMethod != OPTIONS && //
contentType != null && (contentType.contains("xml") || contentType.contains("json"));
if (interested) {
final ContentCachingRequestWrapper found = findWrapper(request, ContentCachingRequestWrapper.class);
if (found == null) {
filterChain.doFilter(new ContentCachingRequestWrapper(request), response);
} else {
filterChain.doFilter(request, response);
}
} else {
filterChain.doFilter(request, response);
}
}
}
代码示例来源:origin: cn.home1/oss-lib-errorhandle-spring-boot-1.4.2.RELEASE
@Override
protected void doFilterInternal( //
final HttpServletRequest request, //
final HttpServletResponse response, //
final FilterChain filterChain //
) throws ServletException, IOException {
final RequestMethod requestMethod = RequestMethod.valueOf(request.getMethod());
final String contentType = request.getContentType();
final Boolean interested = requestMethod != GET && requestMethod != OPTIONS && //
contentType != null && (contentType.contains("xml") || contentType.contains("json"));
if (interested) {
final ContentCachingRequestWrapper found = findWrapper(request, ContentCachingRequestWrapper.class);
if (found == null) {
filterChain.doFilter(new ContentCachingRequestWrapper(request), response);
} else {
filterChain.doFilter(request, response);
}
} else {
filterChain.doFilter(request, response);
}
}
}
代码示例来源: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: osiam/server
public Group validateJsonGroup(HttpServletRequest request) throws IOException {
String jsonInput = getRequestBody(request);
Validator validator = validators.get(RequestMethod.valueOf(request.getMethod()));
Group group;
try {
group = validator.validateGroup(jsonInput);
} catch (JsonParseException ex) {
throw new IllegalArgumentException("The JSON structure is invalid", ex);
}
if (group.getSchemas() == null || group.getSchemas().isEmpty() || !group.getSchemas().contains(Constants.GROUP_CORE_SCHEMA)) {
throw new SchemaUnknownException();
}
return group;
}
代码示例来源:origin: de.escalon.hypermedia/spring-hateoas-ext
private static String getModelProperty(String href, ActionDescriptor actionDescriptor) {
RequestMethod httpMethod = RequestMethod.valueOf(actionDescriptor.getHttpMethod());
StringBuffer model = new StringBuffer();
switch (httpMethod) {
case POST:
case PUT:
case PATCH: {
List<UberField> uberFields = new ArrayList<UberField>();
recurseBeanCreationParams(uberFields, actionDescriptor.getRequestBody()
.getParameterType(), actionDescriptor, actionDescriptor.getRequestBody(), actionDescriptor
.getRequestBody()
.getValue(), "", Collections.<String>emptySet());
for (UberField uberField : uberFields) {
if (model.length() > 0) {
model.append("&");
}
model.append(String.format(MODEL_FORMAT, uberField.getName(), uberField.getName()));
}
break;
}
default:
}
return model.length() == 0 ? null : model.toString();
}
代码示例来源:origin: dschulten/hydra-java
private static String getModelProperty(String href, ActionDescriptor actionDescriptor) {
RequestMethod httpMethod = RequestMethod.valueOf(actionDescriptor.getHttpMethod());
StringBuffer model = new StringBuffer();
switch (httpMethod) {
case POST:
case PUT:
case PATCH: {
List<UberField> uberFields = new ArrayList<UberField>();
recurseBeanCreationParams(uberFields, actionDescriptor.getRequestBody()
.getParameterType(), actionDescriptor, actionDescriptor.getRequestBody(), actionDescriptor
.getRequestBody()
.getValue(), "", Collections.<String>emptySet());
for (UberField uberField : uberFields) {
if (model.length() > 0) {
model.append("&");
}
model.append(String.format(MODEL_FORMAT, uberField.getName(), uberField.getName()));
}
break;
}
default:
}
return model.length() == 0 ? null : model.toString();
}
代码示例来源:origin: osiam/server
public User validateJsonUser(HttpServletRequest request) throws IOException {
String jsonInput = getRequestBody(request);
Validator validator = validators.get(RequestMethod.valueOf(request.getMethod()));
User user;
try {
user = validator.validateJsonUser(jsonInput);
} catch (JsonParseException ex) {
throw new IllegalArgumentException("The JSON structure is invalid", ex);
}
if (user.getSchemas() == null || user.getSchemas().isEmpty() || !user.getSchemas().contains(Constants.USER_CORE_SCHEMA)) {
throw new SchemaUnknownException();
}
if (user.getId() != null && !user.getId().isEmpty()) {
user = new User.Builder(user).setId(null).build();
}
return user;
}
代码示例来源: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);
}
}
代码示例来源:origin: jtalks-org/jcommune
/**
* {@inheritDoc}
*/
@Override
protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception {
String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
MethodAwareKey key = new MethodAwareKey(RequestMethod.valueOf(request.getMethod()), getUniformUrl(lookupPath));
//We should clear map in case if plugin version was changed
pluginHandlerMethods.clear();
//We should update Web plugins before resolving handler
pluginLoader.reloadPlugins(new TypeFilter(WebControllerPlugin.class));
HandlerMethod handlerMethod = findHandlerMethod(key);
if (handlerMethod != null) {
RequestMappingInfo mappingInfo = getMappingForMethod(handlerMethod.getMethod(), handlerMethod.getBeanType());
//IMPORTANT: Should be called to set request attributes which allows resolve path variables
handleMatch(mappingInfo, lookupPath, request);
return handlerMethod;
} else {
return super.getHandlerInternal(request);
}
}
代码示例来源:origin: dschulten/hydra-java
/**
* Converts single link to uber node.
*
* @param href
* to use
* @param actionDescriptor
* to use for action and model, never null
* @param rels
* of the link
* @return uber link
*/
public static UberNode toUberLink(String href, ActionDescriptor actionDescriptor, List<String> rels) {
Assert.notNull(actionDescriptor, "actionDescriptor must not be null");
UberNode uberLink = new UberNode();
uberLink.setRel(rels);
PartialUriTemplateComponents partialUriTemplateComponents = new PartialUriTemplate(href).expand(Collections
.<String, Object>emptyMap());
uberLink.setUrl(partialUriTemplateComponents.toString());
uberLink.setTemplated(partialUriTemplateComponents.hasVariables() ? Boolean.TRUE : null);
uberLink.setModel(getModelProperty(href, actionDescriptor));
if (actionDescriptor != null) {
RequestMethod requestMethod = RequestMethod.valueOf(actionDescriptor.getHttpMethod());
uberLink.setAction(UberAction.forRequestMethod(requestMethod));
}
return uberLink;
}
代码示例来源:origin: de.escalon.hypermedia/spring-hateoas-ext
/**
* Converts single link to uber node.
*
* @param href
* to use
* @param actionDescriptor
* to use for action and model, never null
* @param rels
* of the link
* @return uber link
*/
public static UberNode toUberLink(String href, ActionDescriptor actionDescriptor, List<String> rels) {
Assert.notNull(actionDescriptor, "actionDescriptor must not be null");
UberNode uberLink = new UberNode();
uberLink.setRel(rels);
PartialUriTemplateComponents partialUriTemplateComponents = new PartialUriTemplate(href).expand(Collections
.<String, Object>emptyMap());
uberLink.setUrl(partialUriTemplateComponents.toString());
uberLink.setTemplated(partialUriTemplateComponents.hasVariables() ? Boolean.TRUE : null);
uberLink.setModel(getModelProperty(href, actionDescriptor));
if (actionDescriptor != null) {
RequestMethod requestMethod = RequestMethod.valueOf(actionDescriptor.getHttpMethod());
uberLink.setAction(UberAction.forRequestMethod(requestMethod));
}
return uberLink;
}
内容来源于网络,如有侵权,请联系作者删除!