public class UrlEncoder extends Object
Constructor and Description |
---|
UrlEncoder() |
Modifier and Type | Method and Description |
---|---|
static String |
encodeAll(String url)
编码URL,默认使用UTF-8编码
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。。 |
static String |
encodeAll(String url,
Charset charset)
编码URL
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
static String |
encodeBlank(CharSequence urlStr)
单独编码URL中的空白符,空白符编码为%20
|
static String |
encodeQuery(String url)
编码URL,默认使用UTF-8编码
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
static String |
encodeQuery(String url,
Charset charset)
编码字符为URL中查询语句
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
public static String encodeAll(String url)
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
url
- URLHutoolException
- UnsupportedEncodingExceptionpublic static String encodeAll(String url, Charset charset) throws HutoolException
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
url
- URLcharset
- 编码,为null表示不编码HutoolException
- UnsupportedEncodingExceptionpublic static String encodeQuery(String url)
url
- URLpublic static String encodeQuery(String url, Charset charset)
url
- 被编码内容charset
- 编码public static String encodeBlank(CharSequence urlStr)
urlStr
- URL字符串Copyright © 2025. All rights reserved.