对url进行解析,可以参考org.apache.http.client.utils 包下面的URLEncodedUtils类
Class URLEncodedUtils
Class URLEncodedUtils
具体参见:http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/utils/URLEncodedUtils.html
Method Summary
| Modifier and Type | Method and Description |
|---|---|
static String | format(Iterable<? extends NameValuePair> parameters, Charset charset)
Returns a String that is suitable for use as an
application/x-www-form-urlencoded list of parameters in an HTTP PUT or HTTP POST.
|
static String | format(List<? extends NameValuePair> parameters, String encoding)
Returns a String that is suitable for use as an
application/x-www-form-urlencoded list of parameters in an HTTP PUT or HTTP POST.
|
static boolean | isEncoded(HttpEntity entity)
Returns true if the entity's Content-Type header is
application/x-www-form-urlencoded.
|
static List<NameValuePair> | parse(HttpEntity entity)
Returns a list of
NameValuePairs as parsed from an
HttpEntity.
|
static void | parse(List<NameValuePair> parameters,Scanner scanner, String charset)
Adds all parameters within the Scanner to the list of
parameters, as encoded by
encoding.
|
static List<NameValuePair> | parse(String s,Charset charset)
Returns a list of
NameValuePairs as parsed from the given string using the given character encoding.
|
static List<NameValuePair> | parse(URI uri,String encoding)
Returns a list of
NameValuePairs as built from the URI's query portion.
|
URL和URI的区别:待完善
本文探讨了如何解析URL,并提供了使用Apache HttpClient库中的URLEncodedUtils类的方法。包括格式化参数为应用/x-www-form-urlencoded格式,解析实体是否编码,以及从HTTP实体中解析名称值对。
1017

被折叠的 条评论
为什么被折叠?



