Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Jeepay
Commits
e0adcf6c
Commit
e0adcf6c
authored
Sep 10, 2021
by
terrfly
Browse files
废弃hutool URL拼接方式;改为自行拼接方式;
parent
ad189f7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/StringKit.java
View file @
e0adcf6c
...
...
@@ -16,6 +16,7 @@
package
com.jeequan.jeepay.core.utils
;
import
cn.hutool.core.net.url.UrlBuilder
;
import
cn.hutool.core.util.URLUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -42,6 +43,36 @@ public class StringKit {
/** 拼接url参数 **/
public
static
String
appendUrlQuery
(
String
url
,
Map
<
String
,
Object
>
map
){
if
(
StringUtils
.
isEmpty
(
url
)
||
map
==
null
||
map
.
isEmpty
()){
return
url
;
}
StringBuilder
sb
=
new
StringBuilder
(
url
);
if
(
url
.
indexOf
(
"?"
)
<
0
){
sb
.
append
(
"?"
);
}
//是否包含query条件
boolean
isHasCondition
=
url
.
indexOf
(
"="
)
>=
0
;
for
(
String
k
:
map
.
keySet
())
{
if
(
k
!=
null
&&
map
.
get
(
k
)
!=
null
){
if
(
isHasCondition
){
sb
.
append
(
"&"
);
//包含了查询条件, 那么应当拼接&符号
}
else
{
isHasCondition
=
true
;
//变更为: 已存在query条件
}
sb
.
append
(
k
).
append
(
"="
).
append
(
URLUtil
.
encodeQuery
(
map
.
get
(
k
).
toString
()));
}
}
return
sb
.
toString
();
}
/** 拼接url参数: 旧版采用Hutool方式(当回调地址是 http://abc.com/#/abc 时存在位置问题) **/
@Deprecated
public
static
String
appendUrlQueryWithHutool
(
String
url
,
Map
<
String
,
Object
>
map
){
if
(
StringUtils
.
isEmpty
(
url
)
||
map
==
null
||
map
.
isEmpty
()){
return
url
;
}
...
...
@@ -55,7 +86,6 @@ public class StringKit {
return
result
.
build
();
}
/** 是否 http 或 https连接 **/
public
static
boolean
isAvailableUrl
(
String
url
){
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment