public String getQueryString(MultiValueMap<String, String> params) {
		if (params.isEmpty()) {
			return "";
		}
		StringBuilder query = new StringBuilder();
		Map<String, Object> singles = new HashMap<>();
		for (String param : params.keySet()) {
			int i = 0;
			for (String value : params.get(param)) {
				query.append("&");
				query.append(param);
				if (!"".equals(value)) { // don't add =, if original is ?wsdl, output is
					// not ?wsdl=
					String key = param;
					// if form feed is already part of param name double
					// since form feed is used as the colon replacement below
					if (key.contains("\f")) {
						key = (FORM_FEED_PATTERN.matcher(key).replaceAll("\f\f"));
					}
					// colon is special to UriTemplate
					if (key.contains(":")) {
						key = COLON_PATTERN.matcher(key).replaceAll("\f");
					}
					key = key + i;
					singles.put(key, value);
					query.append("={");
					query.append(key);
					query.append("}");
				}
				i++;
			}
		}

		UriTemplate template = new UriTemplate("?" + query.toString().substring(1));
		return template.expand(singles).toString();
	}
public String getQueryString ( MultiValueMap < String , String > params ) { if ( params . isEmpty ( ) ) { return "" ; } StringBuilder query = new StringBuilder ( ) ; Map < String , Object > singles = new HashMap < > ( ) ; for ( String param : params . keySet ( ) ) { int i = 0 ; for ( String value : params . get ( param ) ) { query . append ( "&" ) ; query . append ( param ) ; if ( ! "" . equals ( value ) ) { String key = param ; if ( key . contains ( "\f" ) ) { key = ( FORM_FEED_PATTERN . matcher ( key ) . replaceAll ( "\f\f" ) ) ; } if ( key . contains ( ":" ) ) { key = COLON_PATTERN . matcher ( key ) . replaceAll ( "\f" ) ; } key = key + i ; singles . put ( key , value ) ; query . append ( "={" ) ; query . append ( key ) ; query . append ( "}" ) ; } i ++ ; } } UriTemplate template = new UriTemplate ( "?" + query . toString ( ) . substring ( 1 ) ) ; return template . expand ( singles ) . toString ( ) ; }
Get url encoded query string. Pay special attention to single parameters with no
values and parameter names with colon (:) from use of UriTemplate.
@param params Un-encoded request parameters
@return url-encoded query String built from provided parameters