This commit is contained in:
zyy239969 2023-07-20 23:09:00 +08:00
parent b5770e4b11
commit 63ab58093b
1 changed files with 7 additions and 4 deletions

View File

@ -40,6 +40,8 @@ import org.springframework.util.ResourceUtils;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -141,17 +143,18 @@ public class RecruitmentServiceImpl extends BaseService<RecruitmentMapper, Recru
if (StrUtil.isBlank(id)) { if (StrUtil.isBlank(id)) {
throw new ResultException("id不能为空"); throw new ResultException("id不能为空");
} }
// String wordDir = "/upload/word";
File tf = null; File tf = null;
try { try {
// 本地获取模板路径 // 本地获取模板路径
// tf = new File(URLDecoder.decode(Objects.requireNonNull( URL url = ResourceUtils.getURL("/mnt/demo26.ydool.net/doc/象山县国有企业人员招聘报备表.docx");
// Thread.currentThread().getContextClassLoader().getResource("doc/app.docx")).getPath(), "UTF-8")); String filePath = URLDecoder.decode(url.getPath(), "UTF-8");
tf = new File(ResourceUtils.getURL("/mnt/demo26.ydool.net/doc/象山县国有企业人员招聘报备表.docx").getPath()); tf = new File(filePath);
System.out.println("tf.getPath() = " + tf.getPath()); System.out.println("tf.getPath() = " + tf.getPath());
// } catch (UnsupportedEncodingException e) { // } catch (UnsupportedEncodingException e) {
// throw new RuntimeException(e); // throw new RuntimeException(e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }