Constructor and Description |
---|
URLEncodeUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
encode(String url)
编码URL,默认使用UTF-8编码
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
static String |
encode(String url,
Charset charset)
编码字符为 application/x-www-form-urlencoded
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
static String |
encodeAll(String url)
编码URL,默认使用UTF-8编码
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
static String |
encodeAll(String url,
Charset charset)
编码URL
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
static String |
encodeFragment(String url)
编码URL,默认使用UTF-8编码
URL的Fragment URLEncoder 默认的编码器针对Fragment,定义如下: fragment = *( pchar / "/" / "?" |
static String |
encodeFragment(String url,
Charset charset)
URL的Fragment URLEncoder
默认的编码器针对Fragment,定义如下: fragment = *( pchar / "/" / "?" |
static String |
encodePathSegment(String url)
编码URL,默认使用UTF-8编码
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
static String |
encodePathSegment(String url,
Charset charset)
编码字符为URL中查询语句
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
static String |
encodeQuery(String url)
编码URL,默认使用UTF-8编码
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
static String |
encodeQuery(String url,
Charset charset)
编码字符为URL中查询语句
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
public static String encodeAll(String url)
url
- URLUtilException
- UnsupportedEncodingExceptionpublic static String encodeAll(String url, Charset charset) throws UtilException
url
- URLcharset
- 编码,为null表示不编码UtilException
- UnsupportedEncodingExceptionpublic static String encode(String url) throws UtilException
url
- URLUtilException
- UnsupportedEncodingExceptionpublic static String encode(String url, Charset charset)
url
- 被编码内容charset
- 编码public static String encodeQuery(String url) throws UtilException
url
- URLUtilException
- UnsupportedEncodingExceptionpublic static String encodeQuery(String url, Charset charset)
url
- 被编码内容charset
- 编码public static String encodePathSegment(String url) throws UtilException
pchar = unreserved(不处理) / pct-encoded / sub-delims(子分隔符) / "@" unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
url
- URLUtilException
- UnsupportedEncodingExceptionpublic static String encodePathSegment(String url, Charset charset)
pchar = unreserved / pct-encoded / sub-delims / ":" / "@" unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
url
- 被编码内容charset
- 编码public static String encodeFragment(String url) throws UtilException
fragment = *( pchar / "/" / "?" ) pchar = unreserved / pct-encoded / sub-delims / ":" / "@" unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="具体见:https://datatracker.ietf.org/doc/html/rfc3986#section-3.5
url
- 被编码内容UtilException
public static String encodeFragment(String url, Charset charset)
fragment = *( pchar / "/" / "?" ) pchar = unreserved / pct-encoded / sub-delims / ":" / "@" unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="具体见:https://datatracker.ietf.org/doc/html/rfc3986#section-3.5
url
- 被编码内容charset
- 编码Copyright © 2024. All rights reserved.