Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xzxt-app-report
Overview
Overview
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
Administrator
xzxt-app-report
Commits
7c94bb90
Commit
7c94bb90
authored
Feb 27, 2024
by
liulianglang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
字符集
parent
87a2a701
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
src/main/java/org/springblade/founder/forward/controller/ForwardController.java
+2
-2
src/main/java/org/springblade/founder/utils/HttpUtil.java
+3
-1
No files found.
src/main/java/org/springblade/founder/forward/controller/ForwardController.java
View file @
7c94bb90
...
...
@@ -201,7 +201,7 @@ public class ForwardController {
if
(
"undefined"
.
equals
(
data
)||
"null"
.
equals
(
data
)){
data
=
"{}"
;
}
data
=
URLDecoder
.
decode
(
data
);
if
(
""
.
equals
(
data
)){
data
=
"{}"
;
}
...
...
@@ -209,7 +209,7 @@ public class ForwardController {
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
data
);
Map
jsonToMap
=
JSONObject
.
parseObject
(
jsonObject
.
toJSONString
());
System
.
out
.
println
(
"data:=="
+
jsonToMap
);
String
s
=
HttpUtil
.
uploadFile
(
host
+
url
,
file
,
file
.
getName
()
,
headers
,
jsonToMap
);
String
s
=
HttpUtil
.
uploadFile
(
host
+
url
,
file
,
"file"
,
headers
,
jsonToMap
);
return
JSONObject
.
parseObject
(
s
,
R
.
class
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
src/main/java/org/springblade/founder/utils/HttpUtil.java
View file @
7c94bb90
...
...
@@ -539,10 +539,12 @@ public class HttpUtil {
}
MultipartEntityBuilder
builder
=
MultipartEntityBuilder
.
create
();
builder
.
setCharset
(
StandardCharsets
.
UTF_8
);
ContentType
contentType
=
ContentType
.
create
(
"text/plain"
,
Charset
.
forName
(
"UTF-8"
));
builder
.
setMode
(
HttpMultipartMode
.
BROWSER_COMPATIBLE
);
//加上此行代码解决返回中文乱码问题
builder
.
addBinaryBody
(
fileParamName
,
file
.
getInputStream
(),
ContentType
.
MULTIPART_FORM_DATA
,
fileName
);
// 文件流
for
(
Map
.
Entry
<
String
,
String
>
e
:
otherParams
.
entrySet
())
{
builder
.
addTextBody
(
e
.
getKey
(),
String
.
valueOf
(
e
.
getValue
()));
// 类似浏览器表单提交,对应input的name和value
// builder.addTextBody(e.getKey(), String.valueOf(e.getValue()));// 类似浏览器表单提交,对应input的name和value
builder
.
addTextBody
(
e
.
getKey
(),
String
.
valueOf
(
e
.
getValue
()),
contentType
);
}
HttpEntity
entity
=
builder
.
build
();
httpPost
.
setEntity
(
entity
);
...
...
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