Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
RuoYi-Vue-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
融通安全管理系统
RuoYi-Vue-master
Commits
2b915223
Commit
2b915223
authored
Jul 24, 2023
by
周昊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、修改pc端导出风险告知卡图片
parent
1e2af8dd
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
80 deletions
+124
-80
ruoyi-admin/src/main/resources/templates/ftl/word.ftl
ruoyi-admin/src/main/resources/templates/ftl/word.ftl
+103
-54
ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java
...common/src/main/java/com/ruoyi/common/utils/WordUtil.java
+21
-26
No files found.
ruoyi-admin/src/main/resources/templates/ftl/word.ftl
View file @
2b915223
This diff is collapsed.
Click to expand it.
ruoyi-common/src/main/java/com/ruoyi/common/utils/WordUtil.java
View file @
2b915223
...
@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
sun.misc.BASE64Encoder
;
import
sun.misc.BASE64Encoder
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.*
;
...
@@ -91,33 +92,27 @@ public class WordUtil {
...
@@ -91,33 +92,27 @@ public class WordUtil {
* @throws IOException
* @throws IOException
*/
*/
public
static
void
responseDownloadFile
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
filePath
,
String
fileName
)
throws
IOException
{
public
static
void
responseDownloadFile
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
filePath
,
String
fileName
)
throws
IOException
{
// 读到流中
response
.
setCharacterEncoding
(
"utf-8"
);
InputStream
inStream
=
new
FileInputStream
(
filePath
+
fileName
);
response
.
setContentType
(
"application/msword"
);
// 设置浏览器以下载的方式处理该文件名
String
agent
=
request
.
getHeader
(
"User-Agent"
).
toUpperCase
();
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
.
concat
(
String
.
valueOf
(
URLEncoder
.
encode
(
fileName
,
"UTF-8"
))));
String
encodedfileName
=
""
;
// IE
File
file
=
new
File
(
filePath
+
"/"
+
fileName
);
if
(
agent
.
indexOf
(
"MSIE"
)
!=
-
1
||
agent
.
indexOf
(
"TRIDENT"
)
!=
-
1
)
{
try
(
InputStream
fin
=
new
FileInputStream
(
file
);
encodedfileName
=
URLEncoder
.
encode
(
fileName
,
"utf-8"
);
ServletOutputStream
out
=
response
.
getOutputStream
())
{
// 谷歌或火狐
// 缓冲区
}
else
if
(
agent
.
indexOf
(
"CHROME"
)
!=
-
1
||
agent
.
indexOf
(
"FIREFOX"
)
!=
-
1
)
{
byte
[]
buffer
=
new
byte
[
512
];
encodedfileName
=
new
String
(
fileName
.
getBytes
(
"utf-8"
),
"ISO8859-1"
);
int
bytesToRead
;
}
else
{
// 通过循环将读入的Word文件的内容输出到浏览器中
encodedfileName
=
new
String
(
fileName
.
getBytes
(
"utf-8"
),
"ISO8859-1"
);
while
((
bytesToRead
=
fin
.
read
(
buffer
))
!=
-
1
)
{
}
out
.
write
(
buffer
,
0
,
bytesToRead
);
}
// 设置输出的格式
}
catch
(
IOException
e
)
{
response
.
reset
();
e
.
printStackTrace
();
response
.
setContentType
(
"bin"
);
}
finally
{
response
.
addHeader
(
"Content-Disposition"
,
"attachment; filename=\""
+
encodedfileName
+
"\""
);
// 删除临时文件
file
.
delete
();
// 循环取出流中的数据
byte
[]
b
=
new
byte
[
100
];
int
len
;
while
((
len
=
inStream
.
read
(
b
))
>
0
)
{
response
.
getOutputStream
().
write
(
b
,
0
,
len
);
}
}
inStream
.
close
();
}
}
...
...
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