本文整理汇总了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);
}
示例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;
}
示例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");
}
示例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");
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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);
}
}