當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。