参考网址:http://www.wupaas.com/

1.Excel文件的导入导出

项目源码:后台:https://github.com/zhongyushi-git/easypoi-demo-admin.git。

     前端:https://github.com/zhongyushi-git/easypoi-demo.git

!!!说明:源码中可能与下面的介绍的代码稍有差异,请以源码为准。

1.1准备工作

1)首先新建一个SpringBoot的项目,搭建基本的环境访问数据,详见源码。

2)导入easypoi依赖

定义版本

<easypoi.version>4.1.0</easypoi.version>

坐标:这里是以springmvc的坐标导入的,适用大部分功能。如果需求不多,可以直接导入springboot对应的坐标,二者选一。选择依据就是如果报错,就换另一种坐标即可。

 <!--easypoi-->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>${easypoi.version}</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>${easypoi.version}</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>${easypoi.version}</version>
</dependency>

springboot的坐标

<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-spring-boot-starter</artifactId>
<version>3.3.0</version>
</dependency>

3)创建Excel操作的工具类ExcelUtils

package com.example.easypoidemoadmin.utils;

import cn.afterturn.easypoi.cache.manager.POICacheManager;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.ExcelXorHtmlUtil;
import cn.afterturn.easypoi.excel.entity.ExcelToHtmlParams;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.word.WordExportUtil;
import cn.afterturn.easypoi.word.parse.ParseWord07;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException; /**
* Excel导入导出工具类
*/ public class ExcelUtils { /**
* excel 导出
*
* @param list 数据列表
* @param fileName 导出时的excel名称
* @param response
*/
public static void exportExcel(List<Map<String, Object>> list, String fileName, HttpServletResponse response) throws IOException {
defaultExport(list, fileName, response);
} /**
* 默认的 excel 导出
*
* @param list 数据列表
* @param fileName 导出时的excel名称
* @param response
*/
private static void defaultExport(List<Map<String, Object>> list, String fileName, HttpServletResponse response) throws IOException {
//把数据添加到excel表格中
Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF);
downLoadExcel(fileName, response, workbook);
} /**
* excel 导出
*
* @param list 数据列表
* @param pojoClass pojo类型
* @param fileName 导出时的excel名称
* @param response
* @param exportParams 导出参数(标题、sheet名称、是否创建表头,表格类型)
*/
private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response, ExportParams exportParams) throws IOException {
//把数据添加到excel表格中
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
downLoadExcel(fileName, response, workbook);
} /**
* excel 导出
*
* @param list 数据列表
* @param pojoClass pojo类型
* @param fileName 导出时的excel名称
* @param exportParams 导出参数(标题、sheet名称、是否创建表头,表格类型)
* @param response
*/
public static void exportExcel(List<?> list, Class<?> pojoClass, String fileName, ExportParams exportParams, HttpServletResponse response) throws IOException {
defaultExport(list, pojoClass, fileName, response, exportParams);
} /**
* excel 导出
*
* @param list 数据列表
* @param title 表格内数据标题
* @param sheetName sheet名称
* @param pojoClass pojo类型
* @param fileName 导出时的excel名称
* @param response
*/
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, HttpServletResponse response) throws IOException {
defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName, ExcelType.XSSF));
} /**
* excel 导出
*
* @param list 数据列表
* @param title 表格内数据标题
* @param sheetName sheet名称
* @param pojoClass pojo类型
* @param fileName 导出时的excel名称
* @param isCreateHeader 是否创建表头
* @param response
*/
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, boolean isCreateHeader, HttpServletResponse response) throws IOException {
ExportParams exportParams = new ExportParams(title, sheetName, ExcelType.XSSF);
exportParams.setCreateHeadRows(isCreateHeader);
defaultExport(list, pojoClass, fileName, response, exportParams);
} /**
* excel下载
*
* @param fileName 下载时的文件名称
* @param response
* @param workbook excel数据
*/
private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) throws IOException {
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "UTF-8"));
workbook.write(response.getOutputStream());
} catch (Exception e) {
throw new IOException(e.getMessage());
}
} /**
* excel 导入
*
* @param file excel文件
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(MultipartFile file, Class<T> pojoClass) throws IOException {
return importExcel(file, 1, 1, pojoClass);
} /**
* excel 导入
*
* @param filePath excel文件路径
* @param titleRows 表格内数据标题行
* @param headerRows 表头行
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException {
if (StringUtils.isBlank(filePath)) {
return null;
}
ImportParams params = new ImportParams();
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
params.setNeedSave(true);
params.setSaveUrl("/excel/");
try {
return ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
} catch (NoSuchElementException e) {
throw new IOException("模板不能为空");
} catch (Exception e) {
throw new IOException(e.getMessage());
}
} /**
* excel 导入
*
* @param file 上传的文件
* @param titleRows 表格内数据标题行
* @param headerRows 表头行
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException {
if (file == null) {
return null;
}
try {
return importExcel(file.getInputStream(), titleRows, headerRows, pojoClass);
} catch (Exception e) {
throw new IOException(e.getMessage());
}
} /**
* excel 导入
*
* @param inputStream 文件输入流
* @param titleRows 表格内数据标题行
* @param headerRows 表头行
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(InputStream inputStream, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException {
if (inputStream == null) {
return null;
}
ImportParams params = new ImportParams();
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
params.setSaveUrl("/excel/");
params.setNeedSave(true);
try {
return ExcelImportUtil.importExcel(inputStream, pojoClass, params);
} catch (NoSuchElementException e) {
throw new IOException("excel文件不能为空");
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
}

4)创建数据库db2020及表user,执行脚本在根目录下。

5)excel表格要导入的数据文件在项目根路径的template文件夹下

6)使用vue-cli新建一个vue的项目,并安装需要的插件。项目对axios进行了封装,调用的时候,直接在js中使用即可,详见源码。

7)最后一点,要配置文件中加一行配置

#easypoi启用覆盖
spring
main:
allow-bean-definition-overriding: true

1.2导入

excel文件的导入,主要就是把文件上传之后把内容读取出来进行相应的操作。

1)编写controller导入接口,service及dao详见源码。需要注意的是,上述的导入的excel内容必须包含表头和标题,否则读取不到内容。

 /**
* 导入数据
* @param file
* @return
* @throws IOException
*/
@RequestMapping(value = "/import", method = RequestMethod.POST)
public CommonResult importExcel(@RequestParam("file") MultipartFile file) throws IOException {
List<User> list = ExcelUtils.importExcel(file, User.class);
int i = userService.insertByBatch(list);
if (i != 0) {
return new CommonResult(200, "导入成功");
} else {
return new CommonResult(444, "导入失败");
}
}

2)页面导入的组件

  <el-upload class="upload-demo" action="" :limit="1" :http-request="importExcel" :show-file-list="false" :file-list="fileList">
<el-button size="small" type="primary" icon="el-icon-upload">导入</el-button>
</el-upload>

3)页面导入的方法

  //导入
importExcel(param) {
const formData = new FormData()
formData.append('file', param.file)
home.upload(formData).then(res => {
if (res.code == 200) {
this.fileList = []
this.$message.success("导入成功")
this.getList()
} else {
this.$message.error("导入失败")
}
}).catch(err =>{
console.log(err)
this.$message.error("导入失败")
})
} 

1.3导出

导入就是根据查询的条件把查询结果先写到excel表格中,然后下载这个excel即可。

1)编写controller导出接口,service及dao详见源码。

/**
* 导出数据,使用map接收
*
* @param map
* @param response
* @throws IOException
*/
@PostMapping("/exportExcel")
public void exportExcel(@RequestBody Map<String, Object> map, HttpServletResponse response) throws IOException {
IPage<User> iPage = userService.getList((String) map.get("name"), (Integer) map.get("page"), (Integer) map.get("limit"));
ExcelUtils.exportExcel(iPage.getRecords(), (String) map.get("title"), (String) map.get("sheetName"), User.class, (String) map.get("fileName"), response);
}

2)给实体类加注解

package com.example.easypoidemoadmin.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; /**
* @author zhongyushi
* @date 2020/6/24 0024
* @dec 用户实体
*/
@Data
@TableName(value = "User")
public class User { /**
* 用户名
*/
@TableId(value = "username")
@Excel(name = "用户名", orderNum = "0", width = 30)
private String username; /**
* 姓名
*/
@TableField(value = "name")
@Excel(name = "姓名", orderNum = "1", width = 30)
private String name; /**
* 年龄
*/
@TableField(value = "age")
@Excel(name = "年龄", orderNum = "2", width = 30)
private Integer age; /**
* 性别,0表示男,1表示女
*/
@TableField(value = "sex")
@Excel(name = "性别", orderNum = "3", width = 30,replace = {"男_0", "女_1"})
private String sex; /**
* 籍贯
*/
@TableField(value = "address")
@Excel(name = "籍贯", orderNum = "4", width = 30)
private String address;
//对于时间,需要指定导出的格式:exportFormat="yyyy-MM-dd HH:mm:ss"
}

3)页面导出的方法

 //导出
exportExcel() {
this.downloadLoading = true
home.exportExcel({
title: '用户基本信息',
sheetName: '用户信息',
fileName: '用户信息表',
name: this.pageData.name,
page: this.pageData.page,
limit: this.pageData.limit,
}).then(res => {
//使用js下载文件
fileDownload(res, '用户信息表.xlsx')
}).finally(() => {
this.downloadLoading = false;
});
},

这里使用到了js-file-download插件,它是用来帮助下载文件的。当下载文件时,很多时候都是在地址栏输入url后浏览器自动帮忙下载,但是要统一请求方式,就把返回的二进制文件交给js-file-download进行处理后再下载。需要注意的是,这个导出的请求,我封装了一个单独的方法,需要指定响应的方式,否则无法下载后的文件是空的,方法截图如下:

1.4图片的导出

有了上面的导出基础,图片的导出就很简单了。

1)新建一个实体类,用于和上面的实体类区分

package com.example.easypoidemoadmin.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data; /**
* @author zhongyushi
* @date 2020/6/26 0026
* @dec 描述
*/
@Data
public class Company {
@Excel(name = "公司名称",width =20)
private String name; /**
* type为 2 表示字段类型为图片
* imageType为 1 表示从file读取
*/
@Excel(name = "公司logo",width =20,type = 2,imageType = 1)
private String logo; @Excel(name = "公司介绍",width =100)
private String dec; public Company(String name,String logo,String dec){
this.name=name;
this.logo=logo;
this.dec=dec;
}
}

2)创建接口,图片请自行下载。

/**
* 图片的导出
*
* @param response
* @throws IOException
*/
@PostMapping("/imgexport")
public void imgExport(HttpServletResponse response,@RequestBody Map<String, Object> map) throws IOException {
List<Company> list = new ArrayList<>();
//图片的路径自定义,但必须要正确
list.add(new Company("百度", "E:/img/1.jpg", "百度一下你就知道"));
list.add(new Company("腾讯", "E:/img/3.jpg", "腾讯qq,交流的世界"));
list.add(new Company("阿里巴巴", "E:/img/2.jpg", "阿里巴巴,马云的骄傲"));
String fileName = map.get("fileName").toString();
ExcelUtils.exportExcel(list, fileName, fileName, Company.class, fileName, response);
}

3)在页面添加导出的按钮,点击按钮即可进行下载,下载的文件如图

1.5图片的导入

1)给Company对象加上无参构造,否则会出现异常

  public Company(){}

2)导入接口

 /**
* 导入图片
* @param file
* @return
* @throws IOException
*/
@PostMapping("/imgimport")
public CommonResult imgImport(@RequestParam("file") MultipartFile file) throws IOException {
List<Company> list = ExcelUtils.importExcel(file, Company.class);
return new CommonResult(200,"导入成功",list);
}

3)参考excel的导入,添加一个导入的按钮和请求的方法,详见源码

4)点击excel图片上传,把上一步导出的文件进行导入,看到浏览器返回的数据如图

1.6excel模板导出文件

也可以使用固定的模板来导出excel。

1)在工具类添加方法

    /**
* 根据模板生成excel后导出
* @param templatePath 模板路径
* @param map 数据集合
* @param fileName 文件名
* @param response
* @throws IOException
*/
public static void exportExcel(TemplateExportParams templatePath, Map<String, Object> map,String fileName, HttpServletResponse response) throws IOException {
Workbook workbook = ExcelExportUtil.exportExcel(templatePath, map);
downLoadExcel(fileName, response, workbook);
}

2)编写模板excel。截图如下,模板文件在项目根路径的template文件夹下:

在两个大括号里写对应的数据名称。$fe用来遍历数据,fe的写法 fe标志 : list数据 单个元素数据(默认t,不需要写) {{$fe: maplist t.id }}

3)接口

/**
* 使用模板excel导出
*
* @param response
* @throws Exception
*/
@PostMapping("/excelTemplate")
public void makeExcelTemplate(HttpServletResponse response, @RequestBody Map<String, Object> param) throws Exception {
TemplateExportParams templatePath = new TemplateExportParams("E:/excel/用户信息文件模板.xls");
Map<String, Object> map = new HashMap<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
map.put("date", sdf.format(new Date()));
map.put("user", "admin");
IPage<User> ipages = userService.getList("", 1, 10);
map.put("userList", ipages.getRecords());
ExcelUtils.exportExcel(templatePath, map, param.get("fileName").toString(), response);
}

在接口中,指定模板文件的路径,然后给定数据,map的key值要和模板的值保持一致。

4)页面添加按钮和请求方法,见源码。点击即可下载。

1.7excel转html

1)在工具类添加方法

    /**
* excel转html预览
* @param filePath 文件路径
* @param response
* @throws Exception
*/
public static void excelToHtml(String filePath,HttpServletResponse response) throws Exception{
ExcelToHtmlParams params = new ExcelToHtmlParams(WorkbookFactory.create(POICacheManager.getFile(filePath)),true);
response.getOutputStream().write(ExcelXorHtmlUtil.excelToHtml(params).getBytes());
}

2)编写接口

/**
* EXCEL转html预览
*/
@GetMapping("previewExcel")
public void excelToHtml(HttpServletResponse response) throws Exception {
ExcelUtils.excelToHtml("E:/excel/用户信息导入模板.xlsx",response);
}

3)页面添加按钮和请求方法,见源码。点击即可在弹框中显示。

2.Word文件导出

2.1使用word模板导出

1)在工具类加两个方法

/**
* word下载
*
* @param fileName 下载时的文件名称
* @param response
* @param doc
*/
private static void downLoadWord(String fileName, HttpServletResponse response, XWPFDocument doc) throws IOException {
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/msword");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".docx" , "UTF-8"));
doc.write(response.getOutputStream());
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
/**
* word模板导出
* @param map
* @param templatePath
* @param fileName
* @param response
* @throws Exception
*/
public static void WordTemplateExport(Map<String, Object> map,String templatePath,String fileName,HttpServletResponse response) throws Exception {
XWPFDocument doc = WordExportUtil.exportWord07(templatePath, map);
downLoadWord(fileName,response,doc);
}

2)接口,模板文件在项目根路径的template文件夹下,图片自定义下载(注意:如果要设置图片,必须把导入的jar的版本改为3.3.0,否则会报错,原因是新版本没有这个实体类):

    /**
* 使用模板word导出数据
* @param param
* @param response
*/
@PostMapping("/wordTemplate")
public void makeWordTemplate(@RequestBody Map<String, Object> param,HttpServletResponse response) {
Map<String, Object> map = new HashMap<>();
map.put("name", "张三");
map.put("nativePlace", "湖北武汉");
map.put("age", "20");
map.put("nation", "汉族");
map.put("phone", "15685654524");
map.put("experience", "湖北武汉,工作三年,java工程师");
map.put("evaluate", "优秀,善良,老实");
//设置图片,如果无图片,不设置即可
WordImageEntity image = new WordImageEntity();
image.setHeight(200);
image.setWidth(150);
image.setUrl("E:/excel/pic.jpg");
image.setType(WordImageEntity.URL);
map.put("picture", image);
try {
ExcelUtils.WordTemplateExport(map,"E:/excel/个人简历模板.docx",param.get("fileName").toString(),response);
} catch (Exception e) {
e.printStackTrace();
}
}

3)页面添加按钮和请求方法,见源码。点击即可下载。上面案例导出时有图片,如果不需要图片,可不设置图片路径即可。

2.2使用word模板导出多页

单模板生成多页数据在合适的场景也是需要的,比如一个订单详情信息模板,但是有很多订单,需要导入到一个word里面。

1)在工具类添加方法

    /**
* word模板导出多页
* @param list
* @param templatePath
* @param fileName
* @param response
* @throws Exception
*/
public static void WordTemplateExportMorePage(List<Map<String, Object>> list, String templatePath, String fileName, HttpServletResponse response) throws Exception {
XWPFDocument doc = new ParseWord07().parseWord(templatePath, list);
downLoadWord(fileName, response, doc);
}

2)接口

 /**
* word模板导出多页
* @param param
* @param response
*/
@PostMapping("/wordTemplateMorePage")
public void makeWordTemplateMorePage(@RequestBody Map<String, Object> param, HttpServletResponse response) {
List<Map<String, Object>> list=new ArrayList<>();
for (int i = 0; i < 5; i++) {
Map<String, Object> person = new HashMap<>();
person.put("name", "张三"+i);
person.put("nativePlace", "湖北武汉"+i);
person.put("age", 20+i);
person.put("nation", "汉族");
person.put("phone", "15685654524");
person.put("experience", "湖北武汉,工作三年,java工程师");
person.put("evaluate", "优秀,善良,老实");
person.put("picture", "");
list.add(person);
}
try {
ExcelUtils.WordTemplateExportMorePage(list, "E:/excel/个人简历模板.docx", param.get("fileName").toString(), response);
} catch (Exception e) {
e.printStackTrace();
}
}

3)页面添加按钮和请求方法,见源码。点击即可下载。

easyPOI基本用法的更多相关文章

  1. EasyPOI 教程以及完整工具类的使用

    因为项目的原因需要用到POI来操作Excel 文档,以前都是直接使用POI来操作的,但是最近听到easypoi的存在,所以自己简单的尝试了下! 别说,他还真的挺好用的 Easypoi介绍 Easypo ...

  2. SpringBoot图文教程10—模板导出|百万数据Excel导出|图片导出「easypoi」

    有天上飞的概念,就要有落地的实现 概念十遍不如代码一遍,朋友,希望你把文中所有的代码案例都敲一遍 先赞后看,养成习惯 SpringBoot 图文教程系列文章目录 SpringBoot图文教程1「概念+ ...

  3. vue springboot利用easypoi实现简单导出

    vue springboot利用easypoi实现简单导出 前言 一.easypoi是什么? 二.使用步骤 1.传送门 2.前端vue 3.后端springboot 3.1编写实体类(我这里是dto, ...

  4. Vue+EasyPOI导出Excel(带图片)

    一.前言 平时的工作中,Excel 导入导出功能是非常常见的功能,无论是前端 Vue (js-xlsx) 还是 后端 Java (POI),如果让大家手动编码实现的话,恐怕就很麻烦了,尤其是一些定制化 ...

  5. EasyPoi中@Excel注解中numFormat的使用

    需求说明:使用EasyPoi时导出文件中折扣字段是小数,被测试同学提了一个bug,需要转成百分数导出. 个人觉得应该转百分号只要在@Excel注解里面加个属性即可,但是在网上的easypoi教程中没有 ...

  6. EditText 基本用法

    title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...

  7. jquery插件的用法之cookie 插件

    一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...

  8. Java中的Socket的用法

                                   Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...

  9. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

随机推荐

  1. .Net Core 3.1浏览器后端服务(一) Web API项目搭建

    一.前言 基于CefSharp开发的浏览器项目已有一段时间,考虑到后期数据维护需要Server端来管理,故开启新篇章搭建浏览器后端服务.该项目前期以梳理服务端知识为主,后期将配合CefSharp浏览器 ...

  2. rockchip的yocto编译环境搭建

    作者:良知犹存 转载授权以及围观:欢迎添加微信公众号:Conscience_Remains 总述   嵌入式的朋友们,应该知道Linux驱动开发过程中,需要进行搭建交叉编译工具链环境.移植u-boot ...

  3. zjnu1726 STOGOVI (lca)

    Description Mirko is playing with stacks. In the beginning of the game, he has an empty stack denote ...

  4. POJ - 1654 利用叉积求三角形面积 去 间接求多边形面积

    题意:在一个平面直角坐标系,一个点总是从原点出发,但是每次移动只能移动8个方向的中的一个并且每次移动距离只有1和√2这两种情况,最后一定会回到原点(以字母5结束),请你计算这个点所画出图形的面积 题解 ...

  5. MySQL 多实例及其主从复制

    目录 Mysql 实例 Mysql 多实例 创建多实例目录 编辑配置文件 初始化多实例数据目录 授权目录 启动多实例 连接多实例并验证 Mysql 多实例设置密码 设置密码后连接 Mysql 多实例主 ...

  6. servlet相关知识点

    一.servlet的生命周期 Servlet(Sever Applet),全称是Java Servlet,是用java编写的服务器程序.Servlet是指任何实现了这个Servlet接口的类. ser ...

  7. 缓冲区溢出实验 4 内存管理(类似于malloc free)

    实验环境.代码.及准备 https://www.cnblogs.com/lqerio/p/12870834.html vul4 观察foo函数,可见问题在于最后一次tfree(q).由于之前已经tfr ...

  8. codeforces 876B

    B. Divisiblity of Differences time limit per test 1 second memory limit per test 512 megabytes input ...

  9. mybaits(七)spring整合mybaits

    与 Spring 整合分析 http://www.mybatis.org/spring/zh/index.html 这里我们以传统的 Spring 为例,因为配置更直观,在 Spring 中使用配置类 ...

  10. 记一次getshell

    水文涉及的知识点: Oday的挖掘 可以执行命令,但是有WAF , 命令执行的绕过 机器不出网,无法反弹 Echo写文件,发现只要写入php文件,后缀就重名为*,如1.php 变成1.* 通过上传 l ...