public class UrlUtil extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
UrlUtil.Builder |
| 构造器和说明 |
|---|
UrlUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static UrlUtil.Builder |
build(String path)
Creates URL builder for user-friendly way of building URLs.
|
static UrlUtil.Builder |
build(String path,
boolean encodePath)
Creates URL builder with given path that can be optionally encoded.
|
static String |
decode(String url)
Decodes URL elements.
|
static String |
decode(String source,
String encoding)
Decodes URL elements.
|
static String |
decodeQuery(String source)
Decodes query name or value.
|
static String |
decodeQuery(String source,
String encoding)
Decodes query name or value.
|
static String |
encode(String uri) |
static String |
encode(String uri,
String encoding)
Encodes the given source URI into an encoded String.
|
static String |
encodeFragment(String fragment) |
static String |
encodeFragment(String fragment,
String encoding)
Encodes the given URI fragment with the given encoding.
|
static String |
encodeHost(String host) |
static String |
encodeHost(String host,
String encoding)
Encodes the given URI host with the given encoding.
|
static String |
encodeHttpUrl(String httpUrl) |
static String |
encodeHttpUrl(String httpUrl,
String encoding)
Encodes the given HTTP URI into an encoded String.
|
static String |
encodePath(String path) |
static String |
encodePath(String path,
String encoding)
Encodes the given URI path with the given encoding.
|
static String |
encodePathSegment(String segment) |
static String |
encodePathSegment(String segment,
String encoding)
Encodes the given URI path segment with the given encoding.
|
static String |
encodePort(String port) |
static String |
encodePort(String port,
String encoding)
Encodes the given URI port with the given encoding.
|
static String |
encodeQuery(String query) |
static String |
encodeQuery(String query,
String encoding)
Encodes the given URI query with the given encoding.
|
static String |
encodeQueryParam(String queryParam) |
static String |
encodeQueryParam(String queryParam,
String encoding)
Encodes the given URI query parameter with the given encoding.
|
static String |
encodeScheme(String scheme) |
static String |
encodeScheme(String scheme,
String encoding)
Encodes the given URI scheme with the given encoding.
|
static String |
encodeUserInfo(String userInfo) |
static String |
encodeUserInfo(String userInfo,
String encoding)
Encodes the given URI user info with the given encoding.
|
static String |
getParamValue(String url,
String paramName) |
static Map<String,String> |
httpParseQuery(String queryUri)
解析http请求URI
|
static Map<String,String> |
parseQuery(String query,
char split1,
char split2,
String dupLink)
解析字符串返回map键值对(例:a=1&b=2 => a=1,b=2)
|
static Map |
print(javax.servlet.http.HttpServletRequest request)
获取HTTPrequest的请求参数
|
static String |
removeParam(String url,
String... paramNames) |
static String |
removeParam(String url,
String paramName) |
static String |
setParam(String url,
String paramName,
String paramValue) |
static String |
urlJoin(URL url,
String locationHeader)
Example:
url: http://tt.se/ Location: /start => http://tt.se/start
url: http://localhost/moved_perm Location: / => http://localhost/
url: http://github.com/ Location: http://github.com/ => https://github.com/
(If the new url throws a MalformedURLException the url String representation will be returned.) |
public static String encodeScheme(String scheme, String encoding)
public static String encodeUserInfo(String userInfo, String encoding)
public static String encodeHost(String host, String encoding)
public static String encodePort(String port, String encoding)
public static String encodePath(String path, String encoding)
public static String encodePathSegment(String segment, String encoding)
public static String encodeQuery(String query, String encoding)
public static String encodeQueryParam(String queryParam, String encoding)
public static String encodeFragment(String fragment, String encoding)
public static String encode(String uri, String encoding)
This method does not attempt to encode "=" and "&" characters in query parameter names and query parameter values because they cannot be parsed in a reliable way.
public static String encodeHttpUrl(String httpUrl, String encoding)
This method does not support fragments (#),
as these are not supposed to be sent to the server, but retained by the client.
This method does not attempt to encode "=" and "&" characters in query parameter names and query parameter values because they cannot be parsed in a reliable way.
public static UrlUtil.Builder build(String path)
encoded.public static UrlUtil.Builder build(String path, boolean encodePath)
public static String decode(String source, String encoding)
public static String decodeQuery(String source, String encoding)
public static String urlJoin(URL url, String locationHeader)
url: http://tt.se/ Location: /start => http://tt.se/start
url: http://localhost/moved_perm Location: / => http://localhost/
url: http://github.com/ Location: http://github.com/ => https://github.com/
(If the new url throws a MalformedURLException the url String representation will be returned.)public static Map print(javax.servlet.http.HttpServletRequest request)
request - http请求public static Map<String,String> parseQuery(String query, char split1, char split2, String dupLink)
query - 源参数字符串split1 - 键值对之间的分隔符(例:&)split2 - key与value之间的分隔符(例:=)dupLink - 重复参数名的参数值之间的连接符,连接后的字符串作为该参数的参数值,可为null
null:不允许重复参数名出现,则靠后的参数值会覆盖掉靠前的参数值。Copyright © 2016. All rights reserved.