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


Java UriComponents.getQueryParams方法代码示例

本文整理汇总了Java中org.springframework.web.util.UriComponents.getQueryParams方法的典型用法代码示例。如果您正苦于以下问题:Java UriComponents.getQueryParams方法的具体用法?Java UriComponents.getQueryParams怎么用?Java UriComponents.getQueryParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.util.UriComponents的用法示例。


在下文中一共展示了UriComponents.getQueryParams方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createServiceInfo

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
@Override
public VaultServiceInfo createServiceInfo(String id, String uri) {

	UriComponents uriInfo = UriComponentsBuilder.fromUriString(uri).build();

	String address = UriComponentsBuilder.newInstance() //
			.scheme(uriInfo.getScheme()) //
			.host(uriInfo.getHost()) //
			.port(uriInfo.getPort()) //
			.build().toString();

	MultiValueMap<String, String> queryParams = uriInfo.getQueryParams();

	String token = queryParams.getFirst("token");
	Assert.hasText(token, "Token (token=…) must not be empty");

	Map<String, String> backends = getBackends(queryParams, backendPattern);
	Map<String, String> sharedBackends = getBackends(queryParams,
			sharedBackendPattern);

	return new VaultServiceInfo(id, address, token.toCharArray(), backends,
			sharedBackends);
}
 
开发者ID:pivotal-cf,项目名称:spring-cloud-vault-connector,代码行数:24,代码来源:VaultServiceInfoCreator.java

示例2: isFlashMapForRequest

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
/**
 * Whether the given FlashMap matches the current request.
 * Uses the expected request path and query parameters saved in the FlashMap.
 */
protected boolean isFlashMapForRequest(FlashMap flashMap, HttpServletRequest request) {
	String expectedPath = flashMap.getTargetRequestPath();
	if (expectedPath != null) {
		String requestUri = getUrlPathHelper().getOriginatingRequestUri(request);
		if (!requestUri.equals(expectedPath) && !requestUri.equals(expectedPath + "/")) {
			return false;
		}
	}
	UriComponents uriComponents = ServletUriComponentsBuilder.fromRequest(request).build();
	MultiValueMap<String, String> actualParams = uriComponents.getQueryParams();
	MultiValueMap<String, String> expectedParams = flashMap.getTargetRequestParams();
	for (String expectedName : expectedParams.keySet()) {
		List<String> actualValues = actualParams.get(expectedName);
		if (actualValues == null) {
			return false;
		}
		for (String expectedValue : expectedParams.get(expectedName)) {
			if (!actualValues.contains(expectedValue)) {
				return false;
			}
		}
	}
	return true;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:AbstractFlashMapManager.java

示例3: requiresAuthenticationAndCreatesValidOAuthTokenRequest

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
@Test
public void requiresAuthenticationAndCreatesValidOAuthTokenRequest() throws Exception {
	String redirect = mockMvc.perform(get("/sign/pivotal"))
			.andExpect(status().is3xxRedirection())
			.andReturn().getResponse().getRedirectedUrl();

	UriComponents redirectComponent = UriComponentsBuilder.fromHttpUrl(redirect).build();

	assertThat(redirectComponent.getScheme()).isEqualTo("https");
	assertThat(redirectComponent.getHost()).isEqualTo("github.com");
	MultiValueMap<String, String> params = redirectComponent.getQueryParams();
	assertThat(params.getFirst("client_id")).isEqualTo(config.getMain().getClientId());
	assertThat(urlDecode(params.getFirst("redirect_uri"))).isEqualTo("http://localhost/login/oauth2/github");
	assertThat(params.getFirst("state")).isNotNull();

	String[] scopes = urlDecode(params.getFirst("scope")).split(",");
	assertThat(scopes).containsOnly("user:email");
}
 
开发者ID:pivotalsoftware,项目名称:pivotal-cla,代码行数:19,代码来源:AuthenticationTests.java

示例4: adminRequiresAuthenticationAndCreatesValidOAuthTokenRequest

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
@Test
public void adminRequiresAuthenticationAndCreatesValidOAuthTokenRequest() throws Exception {
	String redirect = mockMvc.perform(get("/admin/cla/link")).andExpect(status().is3xxRedirection()).andReturn()
			.getResponse().getRedirectedUrl();

	UriComponents redirectComponent = UriComponentsBuilder.fromHttpUrl(redirect).build();

	assertThat(redirectComponent.getScheme()).isEqualTo("https");
	assertThat(redirectComponent.getHost()).isEqualTo("github.com");
	MultiValueMap<String, String> params = redirectComponent.getQueryParams();
	assertThat(params.getFirst("client_id")).isEqualTo(config.getMain().getClientId());
	assertThat(urlDecode(params.getFirst("redirect_uri"))).isEqualTo("http://localhost/login/oauth2/github");
	assertThat(params.getFirst("state")).isNotNull();

	String[] scopes = urlDecode(params.getFirst("scope")).split(",");
	assertThat(scopes).containsOnly("user:email", "repo:status", "admin:repo_hook", "admin:org_hook", "read:org");
}
 
开发者ID:pivotalsoftware,项目名称:pivotal-cla,代码行数:18,代码来源:AuthenticationTests.java

示例5: testFromMethodNameWithPathVarAndRequestParam

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
@Test
public void testFromMethodNameWithPathVarAndRequestParam() throws Exception {
	UriComponents uriComponents = fromMethodName(
			ControllerWithMethods.class, "methodForNextPage", "1", 10, 5).build();

	assertThat(uriComponents.getPath(), is("/something/1/foo"));
	MultiValueMap<String, String> queryParams = uriComponents.getQueryParams();
	assertThat(queryParams.get("limit"), contains("5"));
	assertThat(queryParams.get("offset"), contains("10"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:MvcUriComponentsBuilderTests.java

示例6: testFromMethodCallWithPathVarAndRequestParams

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
@Test
public void testFromMethodCallWithPathVarAndRequestParams() {
	UriComponents uriComponents = fromMethodCall(on(
			ControllerWithMethods.class).methodForNextPage("1", 10, 5)).build();

	assertThat(uriComponents.getPath(), is("/something/1/foo"));

	MultiValueMap<String, String> queryParams = uriComponents.getQueryParams();
	assertThat(queryParams.get("limit"), contains("5"));
	assertThat(queryParams.get("offset"), contains("10"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:MvcUriComponentsBuilderTests.java

示例7: testFromMethodCallWithPathVarAndMultiValueRequestParams

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
@Test
public void testFromMethodCallWithPathVarAndMultiValueRequestParams() {
	UriComponents uriComponents = fromMethodCall(on(
			ControllerWithMethods.class).methodWithMultiValueRequestParams("1", Arrays.asList(3, 7), 5)).build();

	assertThat(uriComponents.getPath(), is("/something/1/foo"));

	MultiValueMap<String, String> queryParams = uriComponents.getQueryParams();
	assertThat(queryParams.get("limit"), contains("5"));
	assertThat(queryParams.get("items"), containsInAnyOrder("3", "7"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:MvcUriComponentsBuilderTests.java

示例8: afterConnectionEstablished

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
@Override
public void afterConnectionEstablished(WebSocketSession session) {
    URI uri = session.getUri();
    try {
        UriComponents uc = UriComponentsBuilder.fromUri(uri).build();
        MultiValueMap<String, String> params = uc.getQueryParams();
        String containerId = params.getFirst("container");
        try(TempAuth ta = withAuth(session)) {
            connectToContainer(session, containerId);
        }
    } catch (Exception e) {
        log.error("Can not establish connection for '{}' due to error:", uri, e);
    }
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:15,代码来源:WsTtyHandler.java


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