Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-fileview
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jenkins
slm-fileview
Commits
11d6ad1e
You need to sign in or sign up before continuing.
Commit
11d6ad1e
authored
Jul 09, 2019
by
陈精华
Committed by
kl
Jul 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复文件下载流URL参数中包含中文URL编码不正确导致HTTP-400异常
parent
e57db692
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
19 deletions
+24
-19
DownloadUtils.java
...rter-web/src/main/java/cn/keking/utils/DownloadUtils.java
+24
-19
No files found.
jodconverter-web/src/main/java/cn/keking/utils/DownloadUtils.java
View file @
11d6ad1e
...
...
@@ -123,30 +123,35 @@ public class DownloadUtils {
* 对最有一个路径进行转码
* @param urlAddress
* http://192.168.2.111:8013/demo/Handle中文.zip
* http://192.168.2.111:8013/download?id=1&filename=中文.zip
* @return
*/
private
String
encodeUrlParam
(
String
urlAddress
)
{
String
newUrl
=
""
;
private
String
encodeUrlParam
(
String
urlAddress
){
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
urlAddress
.
length
();
i
++)
{
char
c
=
urlAddress
.
charAt
(
i
);
if
(
c
>=
0
&&
c
<=
255
)
{
sb
.
append
(
c
);
}
else
{
byte
[]
b
;
try
{
String
path
=
""
;
String
param
=
""
;
if
(
urlAddress
.
contains
(
"?"
))
{
path
=
urlAddress
.
substring
(
0
,
urlAddress
.
indexOf
(
"?"
));
param
=
urlAddress
.
substring
(
urlAddress
.
indexOf
(
"?"
));
}
else
{
path
=
urlAddress
;
}
String
lastPath
=
path
.
substring
(
path
.
lastIndexOf
(
"/"
)
+
1
);
String
leftPath
=
path
.
substring
(
0
,
path
.
lastIndexOf
(
"/"
)
+
1
);
String
encodeLastPath
=
URLEncoder
.
encode
(
lastPath
,
"UTF-8"
);
newUrl
+=
leftPath
+
encodeLastPath
;
if
(
urlAddress
.
contains
(
"?"
))
{
newUrl
+=
param
;
//指定需要的编码类型
b
=
String
.
valueOf
(
c
).
getBytes
(
"utf-8"
);
}
catch
(
Exception
ex
)
{
System
.
out
.
println
(
ex
);
b
=
new
byte
[
0
];
}
for
(
int
j
=
0
;
j
<
b
.
length
;
j
++)
{
int
k
=
b
[
j
];
if
(
k
<
0
)
{
k
+=
256
;
}
sb
.
append
(
"%"
+
Integer
.
toHexString
(
k
).
toUpperCase
());
}
}
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
return
newUrl
;
return
sb
.
toString
()
;
}
...
...
Write
Preview
Markdown
is supported
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