ソースを参照

图片转换成base64码进行显示

tags/v1.1.0
qiujinyang 2年前
コミット
2aa11bcc84
1個のファイルの変更7行の追加3行の削除
  1. +7
    -3
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java

+ 7
- 3
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ReportServiceImpl.java ファイルの表示

@@ -42,8 +42,10 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
@@ -503,16 +505,18 @@ public class ReportServiceImpl extends BaseServiceImpl<ReportMapper, Report> imp
//清空缓存
response.reset();
// 定义浏览器响应表头,并定义下载名
String urlFileName = URLEncoder.encode("汤山林场无人机巡检报告【"+ reportInfoVO.getReportNo() + "】.doc", "UTF-8");
//String urlFileName = URLEncoder.encode("汤山林场无人机巡检报告【"+ reportInfoVO.getReportNo() + "】.doc", "UTF-8");
String urlFileName =new String(("汤山林场无人机巡检报告【"+ reportInfoVO.getReportNo() + "】.doc").getBytes(), StandardCharsets.ISO_8859_1);
response.setHeader("Content-Disposition", "attachment;filename=" + urlFileName);
response.setCharacterEncoding("utf-8");
//定义下载的类型
response.setContentType("application/msword;charset=gbk");
response.setContentType("application/msword;charset=utf-8");
OutputStream out;
File files = new File(filePath);

log.info("读出的文件文件地址为:{}",filePath);
FileInputStream inputStream = new FileInputStream(files);
InputStream inputStream = this.getClass().getResourceAsStream(filePath);
//FileInputStream inputStream = //new FileInputStream(files);
//3.通过response获取ServletOutputStream对象(out)
out = response.getOutputStream();
int b = 0;

読み込み中…
キャンセル
保存