• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RequestMethodsRequestCondition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getMappingForMethod

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
	RequestMapping annotation = AnnotatedElementUtils.findMergedAnnotation(method, RequestMapping.class);
	if (annotation != null) {
		return new RequestMappingInfo(
				new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), true, true),
				new RequestMethodsRequestCondition(annotation.method()),
				new ParamsRequestCondition(annotation.params()),
				new HeadersRequestCondition(annotation.headers()),
				new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
				new ProducesRequestCondition(annotation.produces(), annotation.headers()), null);
	}
	else {
		return null;
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:CrossOriginTests.java


示例2: compareTwoHttpMethodsOneParam

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
@Test
public void compareTwoHttpMethodsOneParam() {
	RequestMappingInfo none = new RequestMappingInfo(null, null, null, null, null, null, null);
	RequestMappingInfo oneMethod =
		new RequestMappingInfo(null,
				new RequestMethodsRequestCondition(RequestMethod.GET), null, null, null, null, null);
	RequestMappingInfo oneMethodOneParam =
			new RequestMappingInfo(null,
					new RequestMethodsRequestCondition(RequestMethod.GET),
					new ParamsRequestCondition("foo"), null, null, null, null);

	Comparator<RequestMappingInfo> comparator = new Comparator<RequestMappingInfo>() {
		@Override
		public int compare(RequestMappingInfo info, RequestMappingInfo otherInfo) {
			return info.compareTo(otherInfo, new MockHttpServletRequest());
		}
	};

	List<RequestMappingInfo> list = asList(none, oneMethod, oneMethodOneParam);
	Collections.shuffle(list);
	Collections.sort(list, comparator);

	assertEquals(oneMethodOneParam, list.get(0));
	assertEquals(oneMethod, list.get(1));
	assertEquals(none, list.get(2));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:RequestMappingInfoTests.java


示例3: preFlightRequest

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
@Test
public void preFlightRequest() {
	MockHttpServletRequest request = new MockHttpServletRequest("OPTIONS", "/foo");
	request.addHeader(HttpHeaders.ORIGIN, "http://domain.com");
	request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "POST");

	RequestMappingInfo info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), new RequestMethodsRequestCondition(RequestMethod.POST), null,
			null, null, null, null);
	RequestMappingInfo match = info.getMatchingCondition(request);
	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), new RequestMethodsRequestCondition(RequestMethod.OPTIONS), null,
			null, null, null, null);
	match = info.getMatchingCondition(request);
	assertNotNull(match);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:RequestMappingInfoTests.java


示例4: getMappingForMethod

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
	RequestMapping annotation = AnnotationUtils.findAnnotation(method, RequestMapping.class);
	if (annotation != null) {
		return new RequestMappingInfo(
			new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), true, true),
			new RequestMethodsRequestCondition(annotation.method()),
			new ParamsRequestCondition(annotation.params()),
			new HeadersRequestCondition(annotation.headers()),
			new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
			new ProducesRequestCondition(annotation.produces(), annotation.headers()), null);
	}
	else {
		return null;
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:RequestMappingInfoHandlerMappingTests.java


示例5: createRequestMappingInfo

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
protected RequestMappingInfo createRequestMappingInfo(RequestMapping annotation,
		RequestCondition<?> customCondition,Object handler) {
	//XXX: not used  RequestMapping
	if(annotation == null){
		return createRequestMappingInfo(customCondition, handler);
	}
	String[] value = annotation.value();
	String[] patterns = resolveEmbeddedValuesInPatterns(value);
	
	//XXX:thining 
	//XXX:增加 RequestMapping value is null 时 默认使用方法名称(包括驼峰式和小写式)
	if(patterns == null ||(patterns != null && patterns.length == 0)){
		
		patterns = getPathMaping(handler);
	}
	
	return new RequestMappingInfo(
			new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(),
					this.useSuffixPatternMatch(), this.useTrailingSlashMatch(), this.getFileExtensions()),
			new RequestMethodsRequestCondition(annotation.method()),
			new ParamsRequestCondition(annotation.params()),
			new HeadersRequestCondition(annotation.headers()),
			new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
			new ProducesRequestCondition(annotation.produces(), annotation.headers(), this.getContentNegotiationManager()),
			customCondition);
}
 
开发者ID:thinking-github,项目名称:nbone,代码行数:27,代码来源:ClassMethodNameHandlerMapping.java


示例6: getMatchingCondition

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
/**
 * Checks if all conditions in this request mapping info match the provided request and returns
 * a potentially new request mapping info with conditions tailored to the current request.
 * <p>For example the returned instance may contain the subset of URL patterns that match to
 * the current request, sorted with best matching patterns on top.
 * @return a new instance in case all conditions match; or {@code null} otherwise
 */
public RequestMappingInfo getMatchingCondition(HttpServletRequest request) {
	RequestMethodsRequestCondition methods = this.methodsCondition.getMatchingCondition(request);
	ParamsRequestCondition params = this.paramsCondition.getMatchingCondition(request);
	HeadersRequestCondition headers = this.headersCondition.getMatchingCondition(request);
	ConsumesRequestCondition consumes = this.consumesCondition.getMatchingCondition(request);
	ProducesRequestCondition produces = this.producesCondition.getMatchingCondition(request);

	if (methods == null || params == null || headers == null || consumes == null || produces == null) {
		return null;
	}

	PatternsRequestCondition patterns = this.patternsCondition.getMatchingCondition(request);
	if (patterns == null) {
		return null;
	}

	RequestConditionHolder custom = this.customConditionHolder.getMatchingCondition(request);
	if (custom == null) {
		return null;
	}

	return new RequestMappingInfo(patterns, methods, params, headers, consumes, produces, custom.getCondition());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:31,代码来源:RequestMappingInfo.java


示例7: RequestMappingInfo

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
public RequestMappingInfo(String name, PatternsRequestCondition patterns, RequestMethodsRequestCondition methods,
		ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes,
		ProducesRequestCondition produces, RequestCondition<?> custom) {

	this.name = (StringUtils.hasText(name) ? name : null);
	this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
	this.methodsCondition = (methods != null ? methods : new RequestMethodsRequestCondition());
	this.paramsCondition = (params != null ? params : new ParamsRequestCondition());
	this.headersCondition = (headers != null ? headers : new HeadersRequestCondition());
	this.consumesCondition = (consumes != null ? consumes : new ConsumesRequestCondition());
	this.producesCondition = (produces != null ? produces : new ProducesRequestCondition());
	this.customConditionHolder = new RequestConditionHolder(custom);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:RequestMappingInfo.java


示例8: combine

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
/**
 * Combines "this" request mapping info (i.e. the current instance) with another request mapping info instance.
 * <p>Example: combine type- and method-level request mappings.
 * @return a new request mapping info instance; never {@code null}
 */
@Override
public RequestMappingInfo combine(RequestMappingInfo other) {
	String name = combineNames(other);
	PatternsRequestCondition patterns = this.patternsCondition.combine(other.patternsCondition);
	RequestMethodsRequestCondition methods = this.methodsCondition.combine(other.methodsCondition);
	ParamsRequestCondition params = this.paramsCondition.combine(other.paramsCondition);
	HeadersRequestCondition headers = this.headersCondition.combine(other.headersCondition);
	ConsumesRequestCondition consumes = this.consumesCondition.combine(other.consumesCondition);
	ProducesRequestCondition produces = this.producesCondition.combine(other.producesCondition);
	RequestConditionHolder custom = this.customConditionHolder.combine(other.customConditionHolder);

	return new RequestMappingInfo(name, patterns,
			methods, params, headers, consumes, produces, custom.getCondition());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:RequestMappingInfo.java


示例9: getMatchingCondition

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
/**
 * Checks if all conditions in this request mapping info match the provided request and returns
 * a potentially new request mapping info with conditions tailored to the current request.
 * <p>For example the returned instance may contain the subset of URL patterns that match to
 * the current request, sorted with best matching patterns on top.
 * @return a new instance in case all conditions match; or {@code null} otherwise
 */
@Override
public RequestMappingInfo getMatchingCondition(HttpServletRequest request) {
	RequestMethodsRequestCondition methods = this.methodsCondition.getMatchingCondition(request);
	ParamsRequestCondition params = this.paramsCondition.getMatchingCondition(request);
	HeadersRequestCondition headers = this.headersCondition.getMatchingCondition(request);
	ConsumesRequestCondition consumes = this.consumesCondition.getMatchingCondition(request);
	ProducesRequestCondition produces = this.producesCondition.getMatchingCondition(request);

	if (methods == null || params == null || headers == null || consumes == null || produces == null) {
		if (CorsUtils.isPreFlightRequest(request)) {
			methods = getAccessControlRequestMethodCondition(request);
			if (methods == null || params == null) {
				return null;
			}
		}
		else {
			return null;
		}
	}

	PatternsRequestCondition patterns = this.patternsCondition.getMatchingCondition(request);
	if (patterns == null) {
		return null;
	}

	RequestConditionHolder custom = this.customConditionHolder.getMatchingCondition(request);
	if (custom == null) {
		return null;
	}

	return new RequestMappingInfo(this.name, patterns,
			methods, params, headers, consumes, produces, custom.getCondition());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:41,代码来源:RequestMappingInfo.java


示例10: getAccessControlRequestMethodCondition

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
/**
 * Return a matching RequestMethodsRequestCondition based on the expected
 * HTTP method specified in a CORS pre-flight request.
 */
private RequestMethodsRequestCondition getAccessControlRequestMethodCondition(HttpServletRequest request) {
	String expectedMethod = request.getHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD);
	if (StringUtils.hasText(expectedMethod)) {
		for (RequestMethod method : getMethodsCondition().getMethods()) {
			if (expectedMethod.equalsIgnoreCase(method.name())) {
				return new RequestMethodsRequestCondition(method);
			}
		}
	}
	return null;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:RequestMappingInfo.java


示例11: createRequestMappingInfo2

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
/**
 * Created a RequestMappingInfo from a RequestMapping annotation.
 */
protected RequestMappingInfo createRequestMappingInfo2(RequestMapping annotation, Method method) {
	String[] patterns;
	if (method != null && annotation.value().length == 0) {
		patterns = new String[] { this.createPattern(method.getName()) };
	}
	else {
		patterns = resolveEmbeddedValuesInPatterns(annotation.value());
	}
	Map<String, String> headerMap = new LinkedHashMap<String, String>();
	ExtensiveDomain extensiveDomain = new ExtensiveDomain();
	requestMappingInfoBuilder.getHeaders(annotation, method, extensiveDomain, headerMap);
	// System.out.println("headerMap:" + headerMap);
	String[] headers = new String[headerMap.size()];
	{
		int i = 0;
		for (Entry<String, String> entry : headerMap.entrySet()) {
			String header = entry.getKey() + "=" + entry.getValue();
			headers[i] = header;
			i++;
		}
	}
	RequestCondition<?> customCondition = new ServerNameRequestCondition(extensiveDomain, headers);
	return new RequestMappingInfo(new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(), false, this.useTrailingSlashMatch(), this.getFileExtensions()),
			new RequestMethodsRequestCondition(annotation.method()), new ParamsRequestCondition(annotation.params()), new HeadersRequestCondition(),
			new ConsumesRequestCondition(annotation.consumes(), headers), new ProducesRequestCondition(annotation.produces(), headers, getContentNegotiationManager()), customCondition);
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:30,代码来源:LeopardHandlerMapping.java


示例12: putRequestMappingInfo

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
/**
 * 塞RequestMappingInfo 本身的信息,比如 url ,method,header 等信息进去.
 *
 * @param keyAndValueMap
 *            the key and value map
 * @param requestMappingInfo
 *            the request mapping info
 */
private static void putRequestMappingInfo(Map<String, Object> keyAndValueMap,RequestMappingInfo requestMappingInfo){
    PatternsRequestCondition patternsRequestCondition = requestMappingInfo.getPatternsCondition();
    RequestMethodsRequestCondition requestMethodsRequestCondition = requestMappingInfo.getMethodsCondition();
    HeadersRequestCondition headersRequestCondition = requestMappingInfo.getHeadersCondition();

    keyAndValueMap.put("url", ConvertUtil.toString(patternsRequestCondition.getPatterns(), DEFAULT_CONFIG));
    keyAndValueMap.put("method", ConvertUtil.toString(requestMethodsRequestCondition.getMethods(), DEFAULT_CONFIG));
    keyAndValueMap.put("header", ConvertUtil.toString(headersRequestCondition.getExpressions(), DEFAULT_CONFIG));
}
 
开发者ID:venusdrogon,项目名称:feilong-spring,代码行数:18,代码来源:HandlerMethodInfoExtractor.java


示例13: createApiVersionInfo

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
private RequestMappingInfo createApiVersionInfo(ApiVersion annotation, RequestCondition<?> customCondition) {
    String[] values = annotation.value();
    String[] patterns = new String[values.length];
    for (int i = 0; i < values.length; i++) {
        // Build the URL prefix
        patterns[i] = prefix + values[i];
    }

    return new RequestMappingInfo(
            new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(), useSuffixPatternMatch(),
                    useTrailingSlashMatch(), getFileExtensions()),
            new RequestMethodsRequestCondition(), new ParamsRequestCondition(), new HeadersRequestCondition(),
            new ConsumesRequestCondition(), new ProducesRequestCondition(), customCondition);
}
 
开发者ID:Talend,项目名称:daikon,代码行数:15,代码来源:ApiVersionRequestMappingHandlerMapping.java


示例14: createRequestMappingInfo

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
protected RequestMappingInfo createRequestMappingInfo(RequestMapping annotation, RequestCondition<?> customCondition) {
	return new RequestMappingInfo(
			new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(), false, true),
			new RequestMethodsRequestCondition(annotation.method()),
			new ParamsRequestCondition(annotation.params()),
			new HeadersRequestCondition(annotation.headers()),
			new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
			new ProducesRequestCondition(annotation.produces(), annotation.headers()), 
			customCondition);
}
 
开发者ID:u2ware,项目名称:springfield,代码行数:11,代码来源:HandlerMapping.java


示例15: createRequestMappingInfo

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
/**
 * Created a RequestMappingInfo from a RequestMapping annotation.
 */
protected RequestMappingInfo createRequestMappingInfo(RequestMapping annotation, RequestCondition<?> customCondition) {
	String[] patterns = resolveEmbeddedValuesInPatterns(annotation.value());
	return new RequestMappingInfo(
			new PatternsRequestCondition(patterns, getUrlPathHelper(), getPathMatcher(),
					this.useSuffixPatternMatch, this.useTrailingSlashMatch, this.fileExtensions),
			new RequestMethodsRequestCondition(annotation.method()),
			new ParamsRequestCondition(annotation.params()),
			new HeadersRequestCondition(annotation.headers()),
			new ConsumesRequestCondition(annotation.consumes(), annotation.headers()),
			new ProducesRequestCondition(annotation.produces(), annotation.headers(), getContentNegotiationManager()),
			customCondition);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:16,代码来源:RequestMappingHandlerMapping.java


示例16: RequestMappingInfo

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
/**
 * Creates a new instance with the given request conditions.
 */
public RequestMappingInfo(PatternsRequestCondition patterns, RequestMethodsRequestCondition methods,
		ParamsRequestCondition params, HeadersRequestCondition headers, ConsumesRequestCondition consumes,
		ProducesRequestCondition produces, RequestCondition<?> custom) {

	this.patternsCondition = (patterns != null ? patterns : new PatternsRequestCondition());
	this.methodsCondition = (methods != null ? methods : new RequestMethodsRequestCondition());
	this.paramsCondition = (params != null ? params : new ParamsRequestCondition());
	this.headersCondition = (headers != null ? headers : new HeadersRequestCondition());
	this.consumesCondition = (consumes != null ? consumes : new ConsumesRequestCondition());
	this.producesCondition = (produces != null ? produces : new ProducesRequestCondition());
	this.customConditionHolder = new RequestConditionHolder(custom);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:16,代码来源:RequestMappingInfo.java


示例17: combine

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
/**
 * Combines "this" request mapping info (i.e. the current instance) with another request mapping info instance.
 * <p>Example: combine type- and method-level request mappings.
 * @return a new request mapping info instance; never {@code null}
 */
public RequestMappingInfo combine(RequestMappingInfo other) {
	PatternsRequestCondition patterns = this.patternsCondition.combine(other.patternsCondition);
	RequestMethodsRequestCondition methods = this.methodsCondition.combine(other.methodsCondition);
	ParamsRequestCondition params = this.paramsCondition.combine(other.paramsCondition);
	HeadersRequestCondition headers = this.headersCondition.combine(other.headersCondition);
	ConsumesRequestCondition consumes = this.consumesCondition.combine(other.consumesCondition);
	ProducesRequestCondition produces = this.producesCondition.combine(other.producesCondition);
	RequestConditionHolder custom = this.customConditionHolder.combine(other.customConditionHolder);

	return new RequestMappingInfo(patterns, methods, params, headers, consumes, produces, custom.getCondition());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:RequestMappingInfo.java


示例18: build

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
@Override
public RequestMappingInfo build() {
	ContentNegotiationManager manager = this.options.getContentNegotiationManager();

	PatternsRequestCondition patternsCondition = new PatternsRequestCondition(
			this.paths, this.options.getUrlPathHelper(), this.options.getPathMatcher(),
			this.options.useSuffixPatternMatch(), this.options.useTrailingSlashMatch(),
			this.options.getFileExtensions());

	return new RequestMappingInfo(this.mappingName, patternsCondition,
			new RequestMethodsRequestCondition(methods),
			new ParamsRequestCondition(this.params),
			new HeadersRequestCondition(this.headers),
			new ConsumesRequestCondition(this.consumes, this.headers),
			new ProducesRequestCondition(this.produces, this.headers, manager),
			this.customCondition);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:RequestMappingInfo.java


示例19: getMethodsCondition

import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition; //导入依赖的package包/类
/**
 * Returns the HTTP request methods of this {@link RequestMappingInfo};
 * or instance with 0 request methods, never {@code null}.
 */
public RequestMethodsRequestCondition getMethodsCondition() {
	return this.methodsCondition;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:RequestMappingInfo.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FluentPage类代码示例发布时间:2022-05-22
下一篇:
Java ContainerPort类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap