本文整理汇总了Java中org.springframework.web.util.UriComponentsBuilder.fromUriString方法的典型用法代码示例。如果您正苦于以下问题:Java UriComponentsBuilder.fromUriString方法的具体用法?Java UriComponentsBuilder.fromUriString怎么用?Java UriComponentsBuilder.fromUriString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.util.UriComponentsBuilder
的用法示例。
在下文中一共展示了UriComponentsBuilder.fromUriString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupHttpClient
import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
private void setupHttpClient(String connectionToken, String protocolVersion){
if(client != null){
client.close();
}
UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromUriString("/signalr/connect");
urlBuilder.queryParam("transport", "webSockets");
urlBuilder.queryParam("clientProtocol", protocolVersion);
urlBuilder.queryParam("connectionToken", connectionToken);
urlBuilder.queryParam("connectionData", "[{\"name\":\"corehub\"}]");
String endPoint = urlBuilder.build().encode().toUriString();
HttpClientOptions options = new HttpClientOptions();
options.setMaxWebsocketFrameSize(1000000);
options.setMaxWebsocketMessageSize(1000000);
client = vertx.createHttpClient(options);
connectToBittrex(endPoint);
}
示例2: createStreamUrl
import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
private String createStreamUrl(HttpServletRequest request, Player player, int id, int offset, int duration, Pair<Integer, Dimension> bitRate) {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(getContextPath(request) + "ext/stream/stream.ts");
builder.queryParam("id", id);
builder.queryParam("hls", "true");
builder.queryParam("timeOffset", offset);
builder.queryParam("player", player.getId());
builder.queryParam("duration", duration);
if (bitRate != null) {
builder.queryParam("maxBitRate", bitRate.getFirst());
Dimension dimension = bitRate.getSecond();
if (dimension != null) {
builder.queryParam("size", dimension.width);
builder.queryParam("x", dimension.height);
}
}
jwtSecurityService.addJWTToken(builder);
return builder.toUriString();
}
示例3: addJWTToken
import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
@Test
public void addJWTToken() throws Exception {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(uriString);
String actualUri = service.addJWTToken(builder).build().toUriString();
String jwtToken = UriComponentsBuilder.fromUriString(actualUri).build().getQueryParams().getFirst(
JWTSecurityService.JWT_PARAM_NAME);
DecodedJWT verify = verifier.verify(jwtToken);
Claim claim = verify.getClaim(JWTSecurityService.CLAIM_PATH);
assertEquals(expectedClaimString, claim.asString());
}
示例4: url
import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
public static URI url(String...xs) {
UriComponentsBuilder builder = UriComponentsBuilder
.fromUriString("http://localhost:8000/");
String[] ys = Arrayz.op(String[]::new).intersperse(() -> "/", xs);
Arrays.asList(ys).forEach(builder::path);
return builder.build().toUri();
}
示例5: getURL
import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
/**
* Gets the URL for the client's HTTP request.
* <p/>
*
* @param uriVariables a Map of URI path variables to values in order to expand the URI template
* into a URI.
* @return a URL as a URI referring to the location of the resource requested by the client via
* HTTP.
* @see #getURI()
* @see java.net.URI
* @see org.springframework.web.util.UriComponents
* @see org.springframework.web.util.UriComponentsBuilder
*/
public URI getURL(final Map<String, ?> uriVariables) {
final UriComponentsBuilder uriBuilder =
UriComponentsBuilder.fromUriString(UriUtils.decode(getURI().toString()));
if (isGet() || isDelete()) {
final List<String> pathVariables = getPathVariables();
// get query parameters to append to the URI/URL based on the request parameters that are not
// path variables...
final Map<String, List<Object>> queryParameters =
CollectionUtils.removeKeys(new LinkedMultiValueMap<String, Object>(getParameters()),
new Filter<Map.Entry<String, List<Object>>>() {
@Override
public boolean accept(final Map.Entry<String, List<Object>> entry) {
// GEODE-1469: since stepArgs has json string in there, we will need to encode it
// so that it won't interfere with the expand() call afterwards
if (entry.getKey().contains(CLIMultiStepHelper.STEP_ARGS)) {
List<Object> stepArgsList = entry.getValue();
if (stepArgsList != null) {
String stepArgs = (String) stepArgsList.remove(0);
stepArgsList.add(UriUtils.encode(stepArgs));
}
}
return !pathVariables.contains(entry.getKey());
}
});
for (final String queryParameterName : queryParameters.keySet()) {
uriBuilder.queryParam(queryParameterName,
getParameters().get(queryParameterName).toArray());
}
}
return uriBuilder.build().expand(UriUtils.encode(new HashMap<String, Object>(uriVariables)))
.encode().toUri();
}
示例6: invoke
import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
@Override
public <T, R> ResponseEntity<T> invoke(RequestDefinition requestDefinition, HttpMethod method,
RequestEntity<R> requestEntity, ResponseType<T> responseType, boolean onlySuccessfulStatusCode) {
// URI
final UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(requestDefinition.getRequestURI());
// query parameters
requestDefinition.getQueryParameters().forEach((n, v) -> builder.queryParam(n, v));
// template parameters
final String uri = builder.buildAndExpand(requestDefinition.getTemplateParameters()).toUriString();
// headers
HttpHeaders headers = new HttpHeaders();
requestDefinition.getHeaders().forEach((n, v) -> headers.add(n, v));
// Entity
HttpEntity<?> entity = new HttpEntity<>(getRequestPayload(requestEntity), headers);
// method
org.springframework.http.HttpMethod requestMethod = org.springframework.http.HttpMethod
.resolve(method.getMethodName());
if (requestMethod == null) {
throw new RestClientException("Unsupported HTTP method: " + method.getMethodName());
}
// get response, checking propertySet
final org.springframework.http.ResponseEntity<Resource> response;
if (requestDefinition.getPropertySet().isPresent()) {
response = requestDefinition.getPropertySet().get()
.execute(() -> invoke(uri, requestMethod, entity, responseType));
} else {
response = invoke(uri, requestMethod, entity, responseType);
}
// check error status code
int statusCode = response.getStatusCodeValue();
if (onlySuccessfulStatusCode && !HttpStatus.isSuccessStatusCode(statusCode)) {
throw new UnsuccessfulResponseException(new SpringResponseEntity<>(response, ResponseType.of(byte[].class),
getRestTemplate().getMessageConverters(), requestDefinition.getPropertySet().orElse(null)));
}
return new SpringResponseEntity<>(response, responseType, getRestTemplate().getMessageConverters(),
requestDefinition.getPropertySet().orElse(null));
}