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


Java PatternsRequestCondition类代码示例

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


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

示例1: getMappingForMethod

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的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: matchPatternsCondition

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的package包/类
@Test
public void matchPatternsCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");

	RequestMappingInfo info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo*", "/bar"), null, null, null, null, null, null);
	RequestMappingInfo expected = new RequestMappingInfo(
			new PatternsRequestCondition("/foo*"), null, null, null, null, null, null);

	assertEquals(expected, info.getMatchingCondition(request));

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/**", "/foo*", "/foo"), null, null, null, null, null, null);
	expected = new RequestMappingInfo(
			new PatternsRequestCondition("/foo", "/foo*", "/**"), null, null, null, null, null, null);

	assertEquals(expected, info.getMatchingCondition(request));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:RequestMappingInfoTests.java

示例3: matchParamsCondition

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的package包/类
@Test
public void matchParamsCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
	request.setParameter("foo", "bar");

	RequestMappingInfo info =
			new RequestMappingInfo(
					new PatternsRequestCondition("/foo"), null,
					new ParamsRequestCondition("foo=bar"), null, null, null, null);
	RequestMappingInfo match = info.getMatchingCondition(request);

	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null,
			new ParamsRequestCondition("foo!=bar"), null, null, null, null);
	match = info.getMatchingCondition(request);

	assertNull(match);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:RequestMappingInfoTests.java

示例4: matchHeadersCondition

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的package包/类
@Test
public void matchHeadersCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
	request.addHeader("foo", "bar");

	RequestMappingInfo info =
			new RequestMappingInfo(
					new PatternsRequestCondition("/foo"), null, null,
					new HeadersRequestCondition("foo=bar"), null, null, null);
	RequestMappingInfo match = info.getMatchingCondition(request);

	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null, null,
			new HeadersRequestCondition("foo!=bar"), null, null, null);
	match = info.getMatchingCondition(request);

	assertNull(match);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:RequestMappingInfoTests.java

示例5: matchConsumesCondition

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的package包/类
@Test
public void matchConsumesCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
	request.setContentType("text/plain");

	RequestMappingInfo info =
		new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null, null, null,
			new ConsumesRequestCondition("text/plain"), null, null);
	RequestMappingInfo match = info.getMatchingCondition(request);

	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null, null, null,
			new ConsumesRequestCondition("application/xml"), null, null);
	match = info.getMatchingCondition(request);

	assertNull(match);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:RequestMappingInfoTests.java

示例6: matchProducesCondition

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的package包/类
@Test
public void matchProducesCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
	request.addHeader("Accept", "text/plain");

	RequestMappingInfo info =
		new RequestMappingInfo(
				new PatternsRequestCondition("/foo"), null, null, null, null,
				new ProducesRequestCondition("text/plain"), null);
	RequestMappingInfo match = info.getMatchingCondition(request);

	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null, null, null, null,
			new ProducesRequestCondition("application/xml"), null);
	match = info.getMatchingCondition(request);

	assertNull(match);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:RequestMappingInfoTests.java

示例7: matchCustomCondition

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的package包/类
@Test
public void matchCustomCondition() {
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
	request.setParameter("foo", "bar");

	RequestMappingInfo info =
			new RequestMappingInfo(
					new PatternsRequestCondition("/foo"), null, null, null, null, null,
					new ParamsRequestCondition("foo=bar"));
	RequestMappingInfo match = info.getMatchingCondition(request);

	assertNotNull(match);

	info = new RequestMappingInfo(
			new PatternsRequestCondition("/foo"), null,
			new ParamsRequestCondition("foo!=bar"), null, null, null,
			new ParamsRequestCondition("foo!=bar"));
	match = info.getMatchingCondition(request);

	assertNull(match);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:RequestMappingInfoTests.java

示例8: preFlightRequest

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的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

示例9: uriTemplateVariables

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的package包/类
@Test
public void uriTemplateVariables() {
	PatternsRequestCondition patterns = new PatternsRequestCondition("/{path1}/{path2}");
	RequestMappingInfo key = new RequestMappingInfo(patterns, null, null, null, null, null, null);
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/1/2");
	String lookupPath = new UrlPathHelper().getLookupPathForRequest(request);
	this.handlerMapping.handleMatch(key, lookupPath, request);

	@SuppressWarnings("unchecked")
	Map<String, String> uriVariables =
		(Map<String, String>) request.getAttribute(
				HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);

	assertNotNull(uriVariables);
	assertEquals("1", uriVariables.get("path1"));
	assertEquals("2", uriVariables.get("path2"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:RequestMappingInfoHandlerMappingTests.java

示例10: uriTemplateVariablesDecode

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的package包/类
@Test
public void uriTemplateVariablesDecode() {
	PatternsRequestCondition patterns = new PatternsRequestCondition("/{group}/{identifier}");
	RequestMappingInfo key = new RequestMappingInfo(patterns, null, null, null, null, null, null);
	MockHttpServletRequest request = new MockHttpServletRequest("GET", "/group/a%2Fb");

	UrlPathHelper pathHelper = new UrlPathHelper();
	pathHelper.setUrlDecode(false);
	String lookupPath = pathHelper.getLookupPathForRequest(request);

	this.handlerMapping.setUrlPathHelper(pathHelper);
	this.handlerMapping.handleMatch(key, lookupPath, request);

	@SuppressWarnings("unchecked")
	Map<String, String> uriVariables =
		(Map<String, String>) request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);

	assertNotNull(uriVariables);
	assertEquals("group", uriVariables.get("group"));
	assertEquals("a/b", uriVariables.get("identifier"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:RequestMappingInfoHandlerMappingTests.java

示例11: getMappingForMethod

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的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

示例12: createRequestMappingInfo

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的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

示例13: getMatchingCondition

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的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

示例14: createRequestMappingInfo

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的package包/类
protected RequestMappingInfo createRequestMappingInfo(String pattern) {
    String[] patterns = (null == pattern) ? null
            : this.resolveEmbeddedValuesInPatterns(new String[] { pattern });
    return new RequestMappingInfo(new PatternsRequestCondition(patterns,
            this.getUrlPathHelper(), this.getPathMatcher(),
            this.useSuffixPatternMatch(), this.useTrailingSlashMatch(),
            this.getFileExtensions()), null, null, null, null, null,
            null);
}
 
开发者ID:zjtx2017,项目名称:ocmall,代码行数:10,代码来源:PackageURLRequestMappingHandler.java

示例15: createRequestMappingInfo

import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; //导入依赖的package包/类
protected RequestMappingInfo createRequestMappingInfo(String pattern) {
    String[] patterns = (null == pattern) ? null
            : this.resolveEmbeddedValuesInPatterns(new String[]{pattern});
    return new RequestMappingInfo(new PatternsRequestCondition(patterns,
            this.getUrlPathHelper(), this.getPathMatcher(),
            this.useSuffixPatternMatch(), this.useTrailingSlashMatch(),
            this.getFileExtensions()), null, null, null, null, null,
            null);
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:10,代码来源:PackageURLRequestMappingHandlerMapping.java


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