当前位置: 首页 > news >正文

简历生成网站网站推广软件

简历生成网站,网站推广软件,外贸网站有哪些?,中国建设银行官网首页 网站首页引入依赖 <dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-spring-boot-starter</artifactId> </dependency> <!-- 下面的版本需要对应上面依赖中的版本 否则可能会起冲突 --> <!-- 下面的依赖主要是为了使用A…

引入依赖

<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-spring-boot-starter</artifactId>
</dependency>
<!-- 下面的版本需要对应上面依赖中的版本 否则可能会起冲突 -->
<!-- 下面的依赖主要是为了使用Apache原生的WordExtractor对doc后缀文件的解析 -->
<dependency><groupId>org.apache.poi</groupId><artifactId>poi-scratchpad</artifactId><version>4.1.1</version>
</dependency>
<!-- 糊涂Api工具 -->
<dependency><groupId>cn.hutool</groupId><artifactId>hutool-core</artifactId><version>5.8.10</version>
</dependency>

工具类封装

public class WordDocumentUtil {/*** 解析文档文件** @param file 文档文件* @return 文档内容*/public static String parseWord(MultipartFile file) {String wordTxt = "";InputStream stream = null;try {if (file.getOriginalFilename().endsWith(".doc")) {stream = file.getInputStream();// Apache PoiWordExtractor ex = new WordExtractor(stream);wordTxt = ex.getText();} else if (file.getOriginalFilename().endsWith(".docx")) {stream = file.getInputStream();// EasyPoiXWPFDocument document = new XWPFDocument(stream);XWPFWordExtractor ex = new XWPFWordExtractor(document);wordTxt = ex.getText();}} catch (Exception e) {// 此处建议抛出异常 "文档解析有误"e.printStackTrace();} finally {if (stream != null) {try {stream.close();} catch (IOException e) {e.printStackTrace();}}}return wordTxt;}/*** 判断文档类型进行不同的分割方式* ".doc"后缀需要以"\r\n"切割 而".docx"后缀需要以"\n"切割** @param file 文件名:以file.getOriginalFilename()传入* @param wordTxt 文件内容* @return 内容数组*/public static String[] judgeType(String file, String wordTxt) {boolean suffixFlag = file.endsWith(".doc");return suffixFlag ? Arrays.stream(wordTxt.split("\r\n")).toArray(String[]::new): Arrays.stream(wordTxt.split("\n")).toArray(String[]::new);}/*** 导出resources下的word模板表** @param fileName 文件名* @param response {@link HttpServletResponse}*/public void exportTemplate(String fileName, HttpServletResponse response) {InputStream inputStream = null;try {String path = "/word/" + fileName;inputStream = this.getClass().getResourceAsStream(path);String newFileName = IdUtil.simpleUUID() + StrUtil.DOT + FileUtil.extName(fileName);byte[] bytes = new byte[1024 * 1024];// 输入流读取文件if (inputStream != null) {inputStream.read(bytes);}response.setCharacterEncoding("UTF-8");response.setContentType("application/msword");response.setHeader("Access-Control-Expose-Headers","Content-disposition");response.setHeader("Content-Disposition","attachment;filename=" + newFileName);response.getOutputStream().write(bytes);} catch (Exception e) {e.printStackTrace();} finally {if (inputStream != null) {try {inputStream.close();} catch (IOException e) {e.printStackTrace();}}}}
}

乱码问题

        如果这里造成了读取resources下的文件返回前端乱码问题:除了HttpServletResponse响应中设置字体问题,还有可能是因为在编译期文件就已经乱码了,所以需要在pom.xml中增加以下配置。

<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-resources-plugin</artifactId><version>2.6</version><configuration><encoding>UTF-8</encoding><nonFilteredFileExtensions><nonFilteredFileExtension>doc</nonFilteredFileExtension></nonFilteredFileExtensions></configuration></plugin></plugins>
</build>
http://www.khdw.cn/news/31099.html

相关文章:

  • 做网站感想seo主要做哪些工作
  • 网站ui设计给用户提交什么关键词歌词表达的意思
  • 网站建设的工作在哪里找客户资源网络营销软文范文
  • 做网站的软件帝国怎么做网络广告
  • 沈阳优化推广哪家好seo推广软件下载
  • 网站后台怎么添加栏目seo推广是什么
  • 怎么推广我的网站唐山seo排名
  • 电商新手入门知识seo是啥意思
  • web网站开发实例深圳网络营销策划公司
  • 广州网站建设制作公司广州网站快速排名
  • 济南城乡建设网站郑州seo课程
  • 客户网站做供应商自荐有用吗网络营销网络推广
  • 网站首页banner新东方留学机构官网
  • 博彩老虎机网站可做代理吗sem竞价账户托管
  • 海口做网站站长统计入口
  • 博客网站建设方案有实力的网站排名优化软件
  • 设计公司网站设计方案网站推广seo教程
  • 做网站_你的出路在哪里网站域名查询工具
  • 学校网站在哪里找推广运营公司哪家好
  • 企业网站优化要多少钱郴州seo网络优化
  • 网站网站建设百度广告
  • 北京建设网站的江苏提升关键词排名收费
  • 成都网站建设公司排行官网seo关键词排名系统
  • 网站建设培训珠海黄页网站推广
  • 做一些好玩的个人网站百度seo效果怎么样
  • 做网站激励语seo专业培训班
  • 做网站用框架好吗百度公司简介介绍
  • 如何做一名网站编辑怎么做百度搜索排名
  • 济宁专业做网站成都高薪seo
  • 虚拟机建设网站如何推广自己的微信公众号