本文整理汇总了Java中org.apache.http.client.utils.URIBuilder.addParameters方法的典型用法代码示例。如果您正苦于以下问题:Java URIBuilder.addParameters方法的具体用法?Java URIBuilder.addParameters怎么用?Java URIBuilder.addParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.client.utils.URIBuilder
的用法示例。
在下文中一共展示了URIBuilder.addParameters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildUrl
import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
private URI buildUrl(String subPath, List<NameValuePair> queryParams)
{
URIBuilder uB= new URIBuilder()
.setScheme(serverConfig.isUseHTTPS() ? "https" : "http")
.setHost(serverConfig.getServerName())
.setUserInfo(serverConfig.getUserName(), serverConfig.getPassword())
.setPath(subPath);
if (queryParams != null)
{
uB.addParameters(queryParams);
}
try {
return uB.build();
} catch (URISyntaxException e) {
throw new NextcloudApiException(e);
}
}
示例2: getUrl
import org.apache.http.client.utils.URIBuilder; //导入方法依赖的package包/类
/**
* Creates a full URL for a given path with additional parameters. Same as {@link #getUrl(String)}, but adds the parameters in the URI.
*
* @param path path relative to server url; can start with / but should not include the server context path
* @param parameters url parameters to be added to the url. If the given argument is {@code null}, nothing will be added to the url.
* If the given argument is an empty array, it will force a "?" at the end of the url.
* @return full url as URI
* @throws IllegalArgumentException if path or parameters cannot be parsed into an URI
* @throws NullPointerException if path is null
*/
public URI getUrl(String path, List<NameValuePair> parameters) {
// add server url and path
URIBuilder uriBuilder = new URIBuilder(getUrl(path));
// add parameters
if(parameters != null) {
uriBuilder.addParameters(parameters);
}
try {
return uriBuilder.build();
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
}