springboot+poi-tl根据模板导出word(含动态表格和图片),并将导出的文档压缩zip导出

springboot+poi-tl根据模板导出word(含动态表格和图片)

官网:http://deepoove.com/poi-tl/
参考网站:https://blog.csdn.net/M625387195/article/details/124855854

  • pom导入的maven依赖
<dependency><groupId>com.deepoove</groupId><artifactId>poi-tl</artifactId><version>1.12.1</version>
</dependency>
  • 准备模板
    在这里插入图片描述
    文本标签用{{ }},动态表格的字段标签用[]。

  • 代码实现
    3.1 控制器

    package io.renren.modules.sys.controller;
    import io.renren.common.utils.R;
    import io.renren.modules.sys.service.POIService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;/*** @Author: Administrator* @Date: 2024/3/14* @Description:*/
    @RestController
    @RequestMapping("/anli")
    public class AnliController {@Autowiredprivate POIService poiService;@GetMapping("/daochu/{renwuId}")public R daochu(@PathVariable("renwuId") Long renwuId) {String zipUrl = poiService.anlidaochu(renwuId);return new R().put("zipUrl", zipUrl);}
    }
    

    3.2 实现类

    package io.renren.modules.sys.service;/*** @Author: Administrator* @Date: 2024/3/4* @Description:*/
    public interface POIService {/*** 案例导出* @param renwuId*/String anlidaochu(Long renwuId);
    }
    
    package io.renren.modules.sys.service.impl;import io.renren.common.utils.word.WordUtils;
    import io.renren.modules.sys.dto.RenwuTemplateDTO;
    import io.renren.modules.sys.service.POIService;
    import io.renren.modules.sys.service.SysRenwuService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.scheduling.annotation.Async;
    import org.springframework.stereotype.Service;import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.List;
    import java.util.UUID;
    import java.util.concurrent.CompletableFuture;
    import java.util.zip.ZipOutputStream;/*** @Author: Administrator* @Date: 2024/3/4* @Description:*/
    @Service
    public class POIServiceImpl implements POIService {@Autowiredprivate SysRenwuService renwuService;@Value("${upload.url}")private String UPLOAD_URL;@Value("${upload.path}")private String UPLOAD_SUFFIX_URL;public String getUPLOAD_URL() {return UPLOAD_URL + getUploadSuffixURL();}public String getUploadSuffixURL() {SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");String dateString = sdf.format(new Date());return UPLOAD_SUFFIX_URL + dateString + "/";}/*** 案例导出* @param renwuId*/@Overridepublic String anlidaochu(Long renwuId) {// 将要生成文档的数据查询出来RenwuTemplateDTO renwuTemplateDTO = renwuService.daochuByRenwuId(renwuId);String url = null;if (renwuTemplateDTO != null) {try {List<String> urlList = WordUtils.piliangDaochu(renwuTemplateDTO);if (urlList != null && urlList.size() > 0) {String name = renwuTemplateDTO.getRenwuName()+"_"+ UUID.randomUUID() +".zip";url =  this.getUploadSuffixURL() + name;FileOutputStream fos = new FileOutputStream(this.getUPLOAD_URL() + name);ZipOutputStream zos = new ZipOutputStream(fos);for (String file : urlList) {WordUtils.addToZipFile(file, zos);}zos.close();fos.close();// 使用异步线程删除文件deleteFilesAsync(urlList);}} catch (Exception e) {throw new RuntimeException(e);}}return url;}@Asyncpublic CompletableFuture<Void> deleteFilesAsync(List<String> urlList) {for (String file : urlList) {File fileToDelete = new File(file);if (fileToDelete.exists()) {if (fileToDelete.delete()) {System.out.println("Deleted file: " + file);} else {System.out.println("Failed to delete file: " + file);}}}return CompletableFuture.completedFuture(null);}
    }
    

    3.3 配置文件

    upload:url: H:/GoTionBackends/2023/resourcespath: /u/cms/www/outPath: H:/GoTionBackends/2023/resources/docprefix: http://xxx.xxx.xxx:8087
    

    3.4 工具类

    package io.renren.common.utils.word;import com.alibaba.fastjson.JSON;
    import com.deepoove.poi.XWPFTemplate;
    import com.deepoove.poi.config.Configure;
    import com.deepoove.poi.data.*;
    import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
    import com.deepoove.poi.policy.PictureRenderPolicy;
    import io.renren.common.utils.word.dto.WordQingdanDetailsDTO;
    import io.renren.modules.sys.dto.RenwuTemplateDTO;
    import io.renren.modules.sys.entity.SysQingdanExtEntity;
    import org.apache.commons.lang.StringUtils;import java.io.*;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.UUID;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;/*** @Author: Administrator* @Date: 2024/3/1* @Description:*/
    public class WordUtils {public static List<String> piliangDaochu(RenwuTemplateDTO renwuTemplate) throws IOException {List<String> urlList = new ArrayList<>();if (renwuTemplate.getQingdanDTOList() != null && renwuTemplate.getQingdanDTOList().size() > 0) {for (int i = 0; i < renwuTemplate.getQingdanDTOList().size(); i++) {renwuTemplate.setQingdanDTO(renwuTemplate.getQingdanDTOList().get(i));String daochuUrl = daochumoban(renwuTemplate);urlList.add(daochuUrl);}} else {String daochuUrl =daochumoban(renwuTemplate);urlList.add(daochuUrl);}return urlList;}public static String daochumoban(RenwuTemplateDTO renwuTemplate) throws IOException {// 为表格的显示绑定行循环LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();// 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析Configure configure = Configure.builder().bind("bz", policy).build();// 图片标签集合List<String> pictureTag = new ArrayList<>();SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");HashMap<String, Object> dataMap = new HashMap<String, Object>() {{//添加文本put("xiangmuName", renwuTemplate.getXiangmuName());put("xiangmuzhouqi", renwuTemplate.getXiangmuzhouqi());put("renwuName", renwuTemplate.getRenwuName());put("renwuzhouqi", sdf.format(renwuTemplate.getStartTime()) + " 至 " + sdf.format(renwuTemplate.getEndTime()));put("description", renwuTemplate.getDescription());String xiangmuLink = "";if (renwuTemplate.getRenwuResourceUrlList() != null && renwuTemplate.getRenwuResourceUrlList().size() > 0) {for (int i = 0; i < renwuTemplate.getRenwuResourceUrlList().size(); i++) {if (i != renwuTemplate.getRenwuResourceUrlList().size()-1) {xiangmuLink += PeizhiConfig.getUploadPrefix() + renwuTemplate.getRenwuResourceUrlList().get(i) + "\n";} else {xiangmuLink += PeizhiConfig.getUploadPrefix() + renwuTemplate.getRenwuResourceUrlList().get(i);}}}put("xiangmulink", xiangmuLink );put("biaoqianName", renwuTemplate.getQingdanDTO() != null ? renwuTemplate.getQingdanDTO().getBiaoqianName() : "");String diliurk = PeizhiConfig.getUploadUrl() + renwuTemplate.getQingdanDTO().getResourceUrl();PictureRenderData pictureRenderData = Pictures.ofStream(Files.newInputStream(Paths.get(diliurk)), PictureType.PNG).size(200, 150).create();put("dililink", pictureRenderData);put("resourceDescription", renwuTemplate.getQingdanDTO() != null ? renwuTemplate.getQingdanDTO().getDescription() : "");put("startYear", renwuTemplate.getQingdanDTO() != null ? renwuTemplate.getQingdanDTO().getStartYear() : "");put("endYear", renwuTemplate.getQingdanDTO() != null ? renwuTemplate.getQingdanDTO().getEndYear(): "");put("area", renwuTemplate.getQingdanDTO() != null ? renwuTemplate.getQingdanDTO().getArea() : "");// 其他业务获取到数据源String testTable = null;if (renwuTemplate.getQingdanDTO() != null && renwuTemplate.getQingdanDTO().getQingdanExtList() != null &&  renwuTemplate.getQingdanDTO().getQingdanExtList().size() > 0) {String str = "";for (int i = 0; i < renwuTemplate.getQingdanDTO().getQingdanExtList().size(); i++) {SysQingdanExtEntity ext = renwuTemplate.getQingdanDTO().getQingdanExtList().get(i);String templateType = null, data = PeizhiConfig.getUploadPrefix() + ext.getResourceUrl();// PictureRenderData pictureRenderData1 = null;if (ext.getTemplateType() == 1) {templateType = "图片";//String dataUrl = PeizhiConfig.getUploadUrl() + ext.getResourceUrl();//pictureRenderData1 = Pictures.ofStream(Files.newInputStream(Paths.get(dataUrl)), PictureType.PNG)//        .size(200, 150).create();} else if (ext.getTemplateType() == 2) {templateType = "附件";} else if (ext.getTemplateType() == 3) {templateType = "音视频";} else if (ext.getTemplateType() == 4) {templateType = "文本";data = ext.getExtText();} else if (ext.getTemplateType() == 5) {templateType = "文档";}String source = StringUtils.isNotBlank(ext.getSource()) ? ext.getSource() : "";data = StringUtils.isNotBlank(data) ? data : "";str += "{\n" +"        \"index\": \"" + (i + 1) + "\",\n" +"        \"templateName\": \"" + ext.getTemplateName() + "\",\n" +"        \"templateType\": \"" + templateType + "\",\n" +"        \"source\": \"" + source + "\",\n" +"        \"data\": \"" + data + "\",\n" +"    },\n";}testTable = "[" + str + "]";}// 内容在表格里循环// JSON使用,需要导入fastjson依赖List<WordQingdanDetailsDTO> forms = JSON.parseArray(testTable, WordQingdanDetailsDTO.class);if (forms != null && forms.size() > 0) {for (int i = 0; i < forms.size(); i++) {put("index" + i, forms.get(i).getIndex());put("templateName" + i, forms.get(i).getTemplateName());put("templateType" + i, forms.get(i).getTemplateType());put("source" + i, forms.get(i).getSource());put("data" + i, forms.get(i).getData());}}put("bz", forms);pictureTag.add("dililink");}};for (String tag : pictureTag ) {//设置图片,不然保存的是一串字符configure.customPolicy(tag, new PictureRenderPolicy());}if (!new File(PeizhiConfig.getUploadOutPath()).exists()) {new File(PeizhiConfig.getUploadOutPath()).mkdirs();}String outPath = PeizhiConfig.getUploadOutPath() + "/"+ UUID.randomUUID() +".docx";// 读取模板、数据并渲染XWPFTemplate template = XWPFTemplate.compile(new FileInputStream(PeizhiConfig.getUploadOutPath() + "/任务数据.docx"), configure).render(dataMap);//  文件是否已存在,则删除File file = new File(outPath);if (file.exists()) {file.delete();}// 生成word保存在指定目录//template.writeToFile(outPath);template.writeAndClose(Files.newOutputStream(Paths.get(outPath)));template.close();return outPath;}public static void addToZipFile(String filePath, ZipOutputStream zos) throws IOException {File file = new File(filePath);FileInputStream fis = new FileInputStream(file);ZipEntry zipEntry = new ZipEntry(file.getName());zos.putNextEntry(zipEntry);byte[] bytes = new byte[1024];int length;while ((length = fis.read(bytes)) >= 0) {zos.write(bytes, 0, length);}zos.closeEntry();fis.close();}public static void createDoc() throws Exception {// 为表格的显示绑定行循环LoopRowTableRenderPolicy policy = new LoopRowTableRenderPolicy();// 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析Configure configure = Configure.builder().bind("bz", policy).build();List<String> pictureTag = new ArrayList<>();// 将需要解析的数据放到dataMap中HashMap<String, Object> dataMap = new HashMap<String, Object>() {{//添加文本put("xiangmuName", "项目名称");put("xiangmuzhouqi", "2024-03-01 至 2024-04-02");put("renwuName", "任务名称");put("renwuzhouqi", "2024-03-05 至 2024-03-26");put("description", "项目描述");put("xiangmulink", "http://www.baidu.com");put("biaoqianName", "标签名称");PictureRenderData pictureRenderData = Pictures.ofStream(Files.newInputStream(Paths.get("D:\\template\\picture\\其他\\yiyan-NewYear.png")), PictureType.PNG).size(200, 150).create();put("dililink", pictureRenderData);put("resourceDescription", "资源描述");put("startYear", "1997");put("endYear", "2018");put("area", "100.5");// 其他业务获取到数据源String testTable = null;{testTable = "[\n" +"    {\n" +"        \"index\": \"1\",\n" +"        \"templateName\": \"模板内容1\",\n" +"        \"templateType\": \"模板类型1\",\n" +"        \"source\": \"来源1\",\n" +"        \"data\": \"http://www.baidu.com\"\n" +"    },\n" +"    {\n" +"        \"index\": \"2\",\n" +"        \"templateName\": \"模板内容2\",\n" +"        \"templateType\": \"模板类型2\",\n" +"        \"source\": \"来源2\",\n" +"        \"data\": \"http://www.baidu.com111\"\n" +"    },\n" +"    {\n" +"        \"index\": \"3\",\n" +"        \"templateName\": \"模板内容3\",\n" +"        \"templateType\": \"模板类型3\",\n" +"        \"source\": \"来源3\",\n" +"        \"data\": \"http://www.baidu.com222\"\n" +"    }\n" +"]";}// 内容在表格里循环// JSON使用,需要导入fastjson依赖List<WordQingdanDetailsDTO> forms = JSON.parseArray(testTable, WordQingdanDetailsDTO.class);for (int i = 0; i < forms.size(); i++) {put("index" + i, forms.get(i).getIndex());put("templateName" + i, forms.get(i).getTemplateName());put("templateType" + i, forms.get(i).getTemplateType());put("source" + i, forms.get(i).getSource());put("data" + i, forms.get(i).getData());}put("bz", forms);pictureTag.add("dililink");}};for (String tag : pictureTag ) {//设置图片,不然保存的是一串字符configure.customPolicy(tag, new PictureRenderPolicy());}String outPath = "D:\\生成数据.docx";// 读取模板、数据并渲染XWPFTemplate template = XWPFTemplate.compile(new FileInputStream("D:\\任务数据.docx"), configure).render(dataMap);//  文件是否已存在,则删除File file = new File(outPath);if (file.exists()) {file.delete();}// 生成word保存在指定目录//template.writeToFile(outPath);template.writeAndClose(Files.newOutputStream(Paths.get(outPath)));template.close();}public static void main(String[] args) throws Exception {createDoc();}}
    

    3.5 用到的实体类

  • RenwuTemplateDTO

    package io.renren.modules.sys.dto;import com.fasterxml.jackson.annotation.JsonFormat;
    import io.renren.common.validator.group.AddGroup;
    import io.renren.common.validator.group.UpdateGroup;
    import io.renren.modules.sys.entity.SysRenwuTemplateEntity;
    import io.renren.modules.sys.entity.SysResourceEntity;
    import io.renren.modules.sys.entity.SysXiangmuEntity;
    import lombok.Data;
    import org.springframework.format.annotation.DateTimeFormat;import javax.validation.constraints.NotBlank;
    import javax.validation.constraints.NotNull;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;/*** @Author: Administrator* @Date: 2023/12/8* @Description:*/
    @Data
    public class RenwuTemplateDTO {private Long renwuId;private Long xiangmuId;private String renwuName;@DateTimeFormat(pattern = "yyyy-MM-dd")@JsonFormat(pattern = "yyyy-MM-dd")private Date startTime;@DateTimeFormat(pattern = "yyyy-MM-dd")@JsonFormat(pattern = "yyyy-MM-dd")private Date endTime;private String description;private String xiangmuName;private String xiangmuzhouqi;private List<SysXiangmuEntity> xiangmuList;private List<SysResourceEntity> fileList = new ArrayList<>();private QingdanDTO qingdanDTO;/*** 用于导出*/private List<QingdanDTO> qingdanDTOList;private List<String> renwuResourceUrlList;
    }
    
  • QingdanDTO

    import com.fasterxml.jackson.annotation.JsonFormat;
    import io.renren.common.validator.group.AddGroup;
    import io.renren.common.validator.group.UpdateGroup;
    import io.renren.modules.sys.entity.SysQingdanExtEntity;
    import lombok.Data;
    import org.springframework.format.annotation.DateTimeFormat;import javax.validation.constraints.NotNull;
    import java.util.Date;
    import java.util.List;/*** @Author: Administrator* @Date: 2023/12/11* @Description:*/
    @Data
    public class QingdanDTO {private Long qingdanId;private Long renwuId;private Long userId;private String biaoqianName;@DateTimeFormat(pattern = "yyyy")@JsonFormat(timezone = "GMT+8", pattern = "yyyy")private String startYear;@DateTimeFormat(pattern = "yyyy")@JsonFormat(timezone = "GMT+8", pattern = "yyyy")private String endYear;private String area;private String resourceUrl;/*** 资源描述*/private String description;private String xiangmuName;private String renwuName;/*** 清单详情*/private List<SysQingdanExtEntity> qingdanExtList;/*** 任务周期*/private String renwuzhouqi;/*** 项目周期*/private String xiangmuzhouqi;}
    
  • SysQingdanExtEntity

    import com.baomidou.mybatisplus.annotation.TableField;
    import com.baomidou.mybatisplus.annotation.TableLogic;
    import lombok.Data;import java.io.Serializable;/*** @Author: Administrator* @Date: 2023/12/11* @Description:*/
    @Data
    public class SysQingdanExtEntity implements Serializable {private static final long serialVersionUID = 1L;private Long qingdanExtId;private Long qingdanId;private String templateName;private Long resourceId;private String source;private String extText;private Integer templateType;private String resourceUrl;
    }
    
  • WordQingdanDetailsDTO

    import lombok.Data;/*** @Author: Administrator* @Date: 2024/3/1* @Description:*/
    @Data
    public class WordQingdanDetailsDTO {/*** 下标序号*/private Integer index;/*** 名称*/private String templateName;/*** 类型*/private String templateType;/*** 来源*/private String source;/*** 数据*/private String data;
    }
  1. 工具类ConvertUtils

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.BeanUtils;import java.util.ArrayList;
    import java.util.Collection;
    import java.util.List;/*** 转换工具类** @author Mark sunlightcs@gmail.com*/
    public class ConvertUtils {private static Logger logger = LoggerFactory.getLogger(ConvertUtils.class);public static <T> T sourceToTarget(Object source, Class<T> target){if(source == null){return null;}T targetObject = null;try {targetObject = target.newInstance();BeanUtils.copyProperties(source, targetObject);} catch (Exception e) {logger.error("convert error ", e);}return targetObject;}public static <T> List<T> sourceToTarget(Collection<?> sourceList, Class<T> target){if(sourceList == null){return null;}List targetList = new ArrayList<>(sourceList.size());try {for(Object source : sourceList){T targetObject = target.newInstance();BeanUtils.copyProperties(source, targetObject);targetList.add(targetObject);}}catch (Exception e){logger.error("convert error ", e);}return targetList;}
    }
    
  2. 导出效果
    在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/276721.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

002——编译鸿蒙(Liteos -a)

目录 一、鸿蒙是什么 二、Kconfig 2.1 概述 2.2 编译器 2.3 make使用 本文章引用了很多韦东山老师的教程内容&#xff0c;算是我学习过程中的笔记吧。如果侵权请联系我。 一、鸿蒙是什么 这里我补充一下对鸿蒙的描述 这张图片是鸿蒙发布时使用的&#xff0c;鸿蒙是一个很…

excel导入功能(适用于vue和react都可)

如图所示&#xff08;需求&#xff09;&#xff1a;点击导入excel后&#xff0c;数据自动新增到列表数据内 这里以vue3 andt 为例 template 标签内代码 &#xff1a; <a-uploadname"file":multiple"true":show-upload-list"false":customR…

iOS 腾讯Pag动画框架-实现PagView的截图功能

背景 产品想要一个首页的截图功能&#xff0c;一听这个功能&#xff0c;心想那还不简单&#xff0c;将父视图控件转换成图片保存就行了。按照这个思路实现&#xff0c;很快就打脸啦&#xff0c;首页的这些动画一个都没有截出来&#xff0c;就像消失啦似的。然后蠢蠢的将动画暂…

一周学会Django5 Python Web开发-Jinja3模版引擎-模板语法

锋哥原创的Python Web开发 Django5视频教程&#xff1a; 2024版 Django5 Python web开发 视频教程(无废话版) 玩命更新中~_哔哩哔哩_bilibili2024版 Django5 Python web开发 视频教程(无废话版) 玩命更新中~共计37条视频&#xff0c;包括&#xff1a;2024版 Django5 Python we…

【pycharm】如何将pacharm设置成中文

【pycharm】汉化教程——如何将pacharm设置成中文 1、打开pycharm 2、点击file 3、点击setting——Plugins——搜索Chinese——点击如下图图标进行下载 汉化后界面情况&#xff1a;

windows使用docker运行TP6使用swoole内置http服务

1&#xff0c;下载docker-Windows客户端 下载地址&#xff1a;https://www.docker.com/products/docker-desktop docker --version #查看docker版本 docker-compose --version #查看docker-compose版本 2&#xff0c;安装环境 使用一键安装包&#xff1a;https://gitee.com/yes…

量子遗传算法优化VMD参数,五种适应度函数任意切换,最小包络熵、样本熵、信息熵、排列熵、排列熵/互信息熵...

关于量子遗传算法&#xff0c;在众多文献均有应用。下面简述一下原理。 &#xff08;1&#xff09;量子比特编码 子遗传算法通过引入量子比特来完成基因的存储和表达。量子比特是量子信息中的概念&#xff0c;它与经典比特不同&#xff0c;是因为它可以在同一时刻处于两个状态的…

通天星CMSV6车载定位监控平台 SQL注入漏洞复现(XVE-2023-23744)

0x01 产品简介 通天星CMSV6车载定位监控平台拥有以位置服务、无线3G/4G视频传输、云存储服务为核心的研发团队,专注于为定位、无线视频终端产品提供平台服务,通天星CMSV6产品覆盖车载录像机、单兵录像机、网络监控摄像机、行驶记录仪等产品的视频综合平台。 0x02 漏洞概述 …

贪心算法(算法竞赛、蓝桥杯)--均分纸牌

1、B站视频链接&#xff1a;A30 贪心算法 P1031 [NOIP2002 提高组] 均分纸牌_哔哩哔哩_bilibili 题目链接&#xff1a;[NOIP2002 提高组] 均分纸牌 - 洛谷 #include <bits/stdc.h> using namespace std; int n,a[101],av,cnt;int main(){scanf("%d",&n);…

AWS云上面的k8s统一日志收集(Fluent Bit+EKS+CW)

目标 k8s上面的常见的统一日志方案是EFK&#xff0c;具体如下&#xff1a; E:elasticsearch;F:fluentd;K:kibana 这里我们变成了使用fluentd的AWS替代品Fluent Bit&#xff0c;直接将日志输出到CloudWatch组。不需要E和K了。不过&#xff0c;这样仅仅用于AWS EKS。 步骤 给…

DFS-验证二叉数98

给你一个二叉树的根节点 root &#xff0c;判断其是否是一个有效的二叉搜索树。 有效 二叉搜索树定义如下&#xff1a; 节点的左 子树 只包含 小于 当前节点的数。节点的右子树只包含 大于 当前节点的数。所有左子树和右子树自身必须也是二叉搜索树。 示例 1&#xff1a; 输入…

初识微信小程序之swiper和swiper-item的基本使用

在我还没接触到微信小程序之前&#xff0c;通常使用轮播要么手写或使用swiper插件去实现&#xff0c;当我接触到微信小程序之后&#xff0c;我看到了微信小程序的强大之处&#xff0c;让我为大家介绍一下吧&#xff01; swiper与swiper-item一起使用可以做轮播图 基本使用&…

运维自动化之——Ansible

目录 一、自动化运维 1、通过xshell实现自动化运维 2、Ansible简介 3、Ansible特点及优势 4、Ansible核心程序 5、Ansible工作原理及流程 6、部署Ansible自动化运维工具 7、Ansible常用模块 ①ansible命令模块 ②command模块 ③shell模块 ④cron模块 ⑤user模块 …

AntPathMatcher【Spring中提供的路径匹配器】

举个例子 我们要求所有以html结尾的访问&#xff0c;都放行 那我们只需要写出用AntPathMatcher判断访问url是否与/**/*.html匹配便可以知道结果

【NLP学习记录】One-Hot编码

1. One-Hot编码概念 one-hot编码的基本思想是将每个类别映射到一个向量&#xff0c;其中只有一个元素的值为1&#xff0c;其余元素的值为0。这样&#xff0c;每个类别之间相互独立&#xff0c;不存在顺序或距离关系。 举例&#xff1a;对于三个类别的情况&#xff0c;可以使用…

uni-app微信小程序上拉加载,下拉刷新

pages.json配置官网链接 onPullDownRefresh、onReachBottom函数跟生命周期同级 data() {return {orderList:[],total: null, //总共多少条数据page: 1,pageSize: 10,} }, onLoad() {}, mounted(){this.getInfo() }, methods:{getInfo(){API.getListxxx().then(res > {const…

JVM的工作流程

目录 1.JVM 简介 2.JVM 执行流程 3. JVM 运行时数据区 3.1 堆&#xff08;线程共享&#xff09; 3.3 本地方法栈&#xff08;线程私有&#xff09; 3.4 程序计数器&#xff08;线程私有&#xff09; 3.5 方法区&#xff08;线程共享&#xff09; 4.JVM 类加载 ① 类…

MM1: Methods, Analysis Insights from Multimodal LLM Pre-training

MM1: Methods, Analysis & Insights from Multimodal LLM Pre-training 相关链接&#xff1a;arxiv 关键字&#xff1a;多模态学习、大型语言模型、预训练、视觉语言连接、混合专家模型 摘要 本文讨论了构建高性能的多模态大型语言模型&#xff08;MLLMs&#xff09;。特别…

uploads-labs靶场(1-10关)

一、搭建环境: 下载upload-labs源代码 下载链接&#xff1a;https://codeload.github.com/c0ny1/upload-labs/zip/refs/heads/master 将压缩包解压后的文件名改为upload-labs&#xff0c;然后放入phpstudy\www目录下 二、关卡通关: 1、pass-01&#xff08;前端绕过&#xf…

(三)丶RabbitMQ的四种类型交换机

前言&#xff1a;四大交换机工作原理及实战应用 1.交换机的概念 交换机可以理解成具有路由表的路由程序&#xff0c;仅此而已。每个消息都有一个称为路由键&#xff08;routing key&#xff09;的属性&#xff0c;就是一个简单的字符串。最新版本的RabbitMQ有四种交换机类型&a…