當前位置: 首頁>>代碼示例>>Java>>正文


Java UriUtils.encodeQueryParam方法代碼示例

本文整理匯總了Java中org.springframework.web.util.UriUtils.encodeQueryParam方法的典型用法代碼示例。如果您正苦於以下問題:Java UriUtils.encodeQueryParam方法的具體用法?Java UriUtils.encodeQueryParam怎麽用?Java UriUtils.encodeQueryParam使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.util.UriUtils的用法示例。


在下文中一共展示了UriUtils.encodeQueryParam方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getQueryString

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
private String getQueryString(ParticipantAddress address) {
	int zip = address.getZip();
	String cityName = address.getCityName();
	String street = address.getStreet();
	String streetNr = address.getStreetNr();

	String result = streetNr + " " + street + ", " + zip;
	if (StringUtils.isNotEmpty(cityName)) {
		result += " " + cityName;
	}

	try {
		result = UriUtils.encodeQueryParam(result, "UTF-8");
	}
	catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}

	return result;
}
 
開發者ID:Clemens85,項目名稱:runningdinner,代碼行數:21,代碼來源:GeocoderServiceGoogleImpl.java

示例2: searchSmartNames

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
private List<Result> searchSmartNames(SearchQuery query, String givenName, String familyName) throws Exception {
    String q = String.format("given-names:%s AND family-name:%s", givenName, familyName);
    String fields = createSearchFieldsQueryString(query);
    if(fields.length() > 0) {
        q += " " + fields;
    }
    String url = String.format("http://pub.orcid.org/v1.2/search/orcid-bio/?rows=%d&q=", query.getLimit()) +
            UriUtils.encodeQueryParam(q, "UTF-8");
    return doSearch(query, url);
}
 
開發者ID:codeforkjeff,項目名稱:conciliator,代碼行數:11,代碼來源:OrcidSmartNames.java

示例3: search

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
@Override
public List<Result> search(SearchQuery query) throws Exception {
    List<Result> results = new ArrayList<>();
    int tries = 0;

    // try twice, first with properties; if no results, try just the main search value
    while(results.size() == 0 && tries < 2) {
        String q = createQuery(query, tries == 0);

        String url = "https://openlibrary.org/search.json?q=" + UriUtils.encodeQueryParam(q, "UTF-8");
        getLog().debug("Making request to " + url);

        HttpURLConnection conn = getConnectionFactory().createConnection(url);

        JsonNode root = mapper.readTree(conn.getInputStream());
        JsonNode docs = root.get("docs");
        if(docs.isArray()) {
            Iterator<JsonNode> iter = docs.iterator();
            while(iter.hasNext() && results.size() < query.getLimit()) {
                JsonNode doc = iter.next();
                String title = doc.get("title").asText();
                String key = doc.get("key").asText();
                results.add(new Result(key, title, bookType, 1.0, false));
            }
        }

        tries++;
    }

    return results;
}
 
開發者ID:codeforkjeff,項目名稱:conciliator,代碼行數:32,代碼來源:OpenLibrary.java

示例4: buildURI

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
private URI buildURI(OTXEndpoints endpoint, Map<OTXEndpointParameters, ?> endpointParametersMap) throws URISyntaxException, MalformedURLException {

        String endpointString = endpoint.getEndpoint();
        if (endpointParametersMap != null) {
            boolean first = true;
            for (Map.Entry<OTXEndpointParameters, ?> otxEndpointParametersEntry : endpointParametersMap.entrySet()) {
                if (otxEndpointParametersEntry.getKey().isRestVariable()) {
                    endpointString = endpointString.replace("{" + otxEndpointParametersEntry.getKey().getParameterName() + "}", otxEndpointParametersEntry.getValue().toString());
                } else {
                    if (first) {
                        endpointString = endpointString + "?";
                        first = false;
                    }
                    try {
                        String parameterName = otxEndpointParametersEntry.getKey().getParameterName();
                        String value = UriUtils.encodeQueryParam(otxEndpointParametersEntry.getValue().toString(), "UTF-8");
                        endpointString = endpointString + String.format("%s=%s&", parameterName, value);
                    } catch (UnsupportedEncodingException e) {
                        log.error("Unpossible");
                    }
                }
            }
        }
        if (otxPort != null) {
            return new URL(otxScheme, otxHost, otxPort, endpointString).toURI();
        } else {
            return new URL(otxScheme, otxHost, endpointString).toURI();
        }
    }
 
開發者ID:AlienVault-OTX,項目名稱:OTX-Java-SDK,代碼行數:30,代碼來源:OTXConnection.java

示例5: searchKeyword

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
protected List<Result> searchKeyword(SearchQuery query) throws Exception {
    String q = createQueryString(query);
    String url = String.format("http://pub.orcid.org/v1.2/search/orcid-bio/?rows=%d&q=", query.getLimit()) +
            UriUtils.encodeQueryParam(q, "UTF-8");
    return doSearch(query, url);
}
 
開發者ID:codeforkjeff,項目名稱:conciliator,代碼行數:7,代碼來源:OrcidBase.java

示例6: testUrlEncodePercentH

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
@Test
public void testUrlEncodePercentH() throws Exception {
    String foo = UriUtils.encodeQueryParam("~1xwbccw58-43436_1", "UTF8");
    assertThat(foo, is("~1xwbccw58-43436_1"));
}
 
開發者ID:KRMAssociatesInc,項目名稱:eHMP,代碼行數:6,代碼來源:CprsSsoVistaAuthenticationFilterTests.java


注:本文中的org.springframework.web.util.UriUtils.encodeQueryParam方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。