Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
notes2.0
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zjm
notes2.0
Commits
396b4b93
提交
396b4b93
authored
5月 27, 2020
作者:
gongwenjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
通知
上级
12d75595
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
7 行增加
和
6 行删除
+7
-6
ExcelController.java
...java/com/zjty/tynotes/pas/controller/ExcelController.java
+6
-5
application.properties
notes-union/src/main/resources/application.properties
+1
-1
没有找到文件。
notes-pas/src/main/java/com/zjty/tynotes/pas/controller/ExcelController.java
浏览文件 @
396b4b93
...
@@ -130,22 +130,23 @@ public class ExcelController {
...
@@ -130,22 +130,23 @@ public class ExcelController {
@ApiOperation
(
value
=
"下载通讯录模板"
)
@ApiOperation
(
value
=
"下载通讯录模板"
)
@PostMapping
(
"/download"
)
@PostMapping
(
"/download"
)
public
ResponseEntity
download
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
public
ResponseEntity
download
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
ClassPathResource
resource
=
new
ClassPathResource
(
"address.xls"
);
String
filename
=
"address.xls"
;
String
filename
=
"address.xls"
;
File
file
=
ResourceUtils
.
getFile
(
"classpath:address.xls"
);
//
File file = ResourceUtils.getFile("classpath:address.xls");
// File file = new File("src/main/resources/address.xls");
// File file = new File("src/main/resources/address.xls");
// System.out.println(addressUrl);
// System.out.println(addressUrl);
// System.out.println("存在??");
// System.out.println("存在??");
if
(
file
.
exists
()){
//判断文件父目录是否存在
//
if(file.exists()){ //判断文件父目录是否存在
// response.setContentType("application/vnd.ms-excel;charset=UTF-8");
// response.setContentType("application/vnd.ms-excel;charset=UTF-8");
// response.setCharacterEncoding("UTF-8");
// response.setCharacterEncoding("UTF-8");
// response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(filename,"UTF-8"));
// response.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(filename,"UTF-8"));
byte
[]
buffer
=
new
byte
[
1024
];
byte
[]
buffer
=
new
byte
[
1024
];
FileInputStream
fis
=
null
;
//文件输入流
InputStream
fis
=
resource
.
getInputStream
()
;
//文件输入流
BufferedInputStream
bis
=
null
;
BufferedInputStream
bis
=
null
;
OutputStream
os
=
null
;
//输出流
OutputStream
os
=
null
;
//输出流
try
{
try
{
os
=
response
.
getOutputStream
();
os
=
response
.
getOutputStream
();
fis
=
new
FileInputStream
(
file
);
//
fis = new FileInputStream(file);
bis
=
new
BufferedInputStream
(
fis
);
bis
=
new
BufferedInputStream
(
fis
);
int
i
=
bis
.
read
(
buffer
);
int
i
=
bis
.
read
(
buffer
);
while
(
i
!=
-
1
){
while
(
i
!=
-
1
){
...
@@ -168,7 +169,7 @@ public class ExcelController {
...
@@ -168,7 +169,7 @@ public class ExcelController {
e
.
printStackTrace
();
e
.
printStackTrace
();
logger
.
error
(
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
());
}
}
}
//
}
return
ok
(
"下载失败"
);
return
ok
(
"下载失败"
);
}
}
...
...
notes-union/src/main/resources/application.properties
浏览文件 @
396b4b93
...
@@ -12,7 +12,7 @@ server.ssl.keyStoreType=PKCS12
...
@@ -12,7 +12,7 @@ server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias
=
alias
server.ssl.keyAlias
=
alias
#mongodb configuration
#mongodb configuration
spring.data.mongodb.uri
=
mongodb://localhost:27017/notes
6
spring.data.mongodb.uri
=
mongodb://localhost:27017/notes
5
# servlet configuration
# servlet configuration
spring.servlet.multipart.max-file-size
=
100MB
spring.servlet.multipart.max-file-size
=
100MB
spring.servlet.multipart.max-request-size
=
1000MB
spring.servlet.multipart.max-request-size
=
1000MB
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论