Java對(duì)Excel表格的上傳和下載處理方法
Excel表格文件的上傳和下載,java中涉及到文件肯定會(huì)有io流的知識(shí)。
而excel文件就要涉及到poi技術(shù),而excel的版本包括:2003-2007和2010兩個(gè)版本, 即excel的后綴名為:xls和xlsx。
這里我是按照正規(guī)的項(xiàng)目流程做的案例,所以可能會(huì)比網(wǎng)上的一些Demo復(fù)雜一些。不過(guò)文件的上傳和下載基本都是一套固定的流程,只是每個(gè)人的實(shí)現(xiàn)方式不太相同。
數(shù)據(jù)庫(kù)我用的是MySql。
下面是我的項(xiàng)目目錄:

按照正常的項(xiàng)目做了分層處理,文件上傳的業(yè)務(wù)我放到了service處理,而文件下載業(yè)務(wù)還在controller層。
對(duì)前端請(qǐng)求處理,我分成了兩個(gè)方法都放在HandleExcelController里面,這個(gè)類繼承了BaseExcelController,基本的文件操作處理在BaseExcelController里面。
BaseExcelController繼承了BaseController,BaseController類是所有controller的父類,這里用到的不太多,這個(gè)類封裝了response返回值等的處理等一些方法。
項(xiàng)目中除了springMVC和mybatis的jar包之外還引入了:

上傳和下載excel文件:
1、創(chuàng)建需要上傳的excel文件,為了簡(jiǎn)化,我這里只寫(xiě)了四列,即四個(gè)字段

2、創(chuàng)建jsp頁(yè)面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Excel文件處理</title>
<script type="text/javascript" src="<c:url value='/res/js/jquery.js'/>"></script>
<script>
$(function(){
var $wrap = $(".wrap");
var find = function(str){
return $wrap.find(str);
}
var getJname = function(name){
return find("input[name='"+name+"']");
}
getJname("Upload").click(function(){
var form = new FormData(document.getElementById("tf"));
$.ajax({
url:"<c:url value='/File/UploadExcel'/>",
type:"post",
data:form,
dataType:"json",
processData:false,
contentType:false,
success:function(data){
//window.clearInterval(timer);
if(data.success == "success"){
alert("提交文件成功,已將數(shù)據(jù)存入數(shù)據(jù)庫(kù)");
}
},
error:function(e){
alert("錯(cuò)誤!");
//window.clearInterval(timer);
}
});
})
getJname("Download").click(function(){
$.post("<c:url value='/File/DownLoadExcel'/>",{"id":"3"},function(data){
//alert("下載文件成功");
},"json")
})
})
</script>
</head>
<body>
<div class="wrap">
<form id="tf">
<p>
<input type="file" name="file" value="選擇文件"/>
Excel文件上傳:<input type="button" name="Upload" value="upload"/>
</p>
<p>
Excel文件下載:<input type="button" name="Download" value="updown"/>
</p>
</form>
</div>
</body>
</html>
3、依次創(chuàng)建controller、service、domain、mapper層,注意它們的依賴關(guān)系
1)、controller層的處理,在HandleExcelController里面注入BaseExcelService。因?yàn)橹皇亲鰝€(gè)示范,所欲我這里將泛型固定為Students類
BaseExcelController代碼:
package cn.wangze.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFPalette;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.CellRangeAddress;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.web.multipart.MultipartFile;
import cn.wangze.domain.Students;
public class BaseExcelController extends BaseController{
//獲取文件的路徑
String separator = System.getProperty("file.separator");
//驗(yàn)證元素是否為空
@SuppressWarnings("all")
public boolean isEmpty(Object obj){
if(obj instanceof Object[]){
if(((Object[]) obj).length==0){
return true;
}
if(obj == null) return true;
if((String.valueOf(obj).trim()).length() == 0){
return true;
}
if(obj instanceof List){
if(((List) obj) == null || ((List)obj).size() == 0){
return true;
}
}
}
return false;
}
/**
* 文件上傳部分
* */
//驗(yàn)證文件
protected boolean checkPathName(String fileName,HttpServletResponse response){
//驗(yàn)證文件是否存在
if(isEmpty(fileName)){
sendError("上傳文件不存在",response);
return false;
}
//驗(yàn)證文件是否是以xls或者xlsx做后綴的文件,如果不是就返回錯(cuò)誤信息
if(!(StringUtils.endsWithIgnoreCase(fileName,".xls")||StringUtils.endsWithIgnoreCase(fileName, ".xlsx"))){
sendError("上傳文件類型錯(cuò)誤,請(qǐng)核對(duì)后重新上傳?",response);
}
return true;
}
//獲取文件的sheet
protected Sheet getSheet(MultipartFile file,String path,String fileName) throws IllegalStateException, IOException{
//找到要存放到項(xiàng)目里面的路徑,新建文件
File targetFile = new File(path, fileName);
targetFile.mkdirs();
if (targetFile.exists()) {
targetFile.delete();
file.transferTo(targetFile);
} else {
file.transferTo(targetFile);
}
//封裝輸入流,封裝sheet里面的內(nèi)容
InputStream is = null;
try{
is = new FileInputStream(path+separator+fileName);
//判斷版本是否為Excel加強(qiáng)版
if(StringUtils.endsWithIgnoreCase(fileName, ".xls")){
return new HSSFWorkbook(is).getSheetAt(0);
}else if(StringUtils.endsWithIgnoreCase(fileName, ".xlsx")){
return new XSSFWorkbook(is).getSheetAt(0);
}
return null;
}
finally{
if(is != null){
is.close();
}
}
}
/**
* 文件下載部分
* */
//根據(jù)傳入的Sting值,判斷生成在excel表的位置
private HSSFCellStyle getPublicStyle(HSSFWorkbook workbook,String key){
HSSFFont font = workbook.createFont();
HSSFCellStyle style = workbook.createCellStyle();
HSSFPalette customPalette = workbook.getCustomPalette();
customPalette.setColorAtIndex(HSSFColor.TEAL.index, (byte) 64, (byte) 148, (byte) 160);
customPalette.setColorAtIndex(HSSFColor.ORANGE.index, (byte) 170, (byte) 204, (byte) 204);
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
if(key=="head"){
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
font.setFontHeightInPoints((short)12);
font.setColor(HSSFColor.TEAL.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
style.setFont(font);
}
if(key=="title"){
font.setColor(HSSFColor.WHITE.index);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setLeftBorderColor(HSSFColor.WHITE.index);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setRightBorderColor(HSSFColor.WHITE.index);
style.setFont(font);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setFillForegroundColor(HSSFColor.ORANGE.index);
style.setFillBackgroundColor(HSSFColor.ORANGE.index);
}
return style;
}
//創(chuàng)建head頭信息
private void createHead(HSSFSheet sheet,HSSFCellStyle style,String[] title){
HSSFRow row1 = sheet.createRow(0);
HSSFCell cellTitle = row1.createCell(0);
cellTitle.setCellValue(new HSSFRichTextString(title[0]));
sheet.addMergedRegion(new CellRangeAddress(0,0,0,title.length-2));
cellTitle.setCellStyle(style);
}
//創(chuàng)建title信息
private void createTitle(HSSFSheet sheet,HSSFCellStyle style,String[] label,int columnNum){
HSSFRow row2 = sheet.createRow(1);
HSSFCell cell1 = null;
for(int n=0;n<columnNum;n++){
cell1 = row2.createCell(n);
cell1.setCellValue(label[n+1]);
cell1.setCellStyle(style);
}
}
//創(chuàng)建content數(shù)據(jù)信息
private void createContent(HSSFSheet sheet,HSSFCellStyle style,Collection<Students> list,int columnNum,String[] parameters){
int index= 0;
Iterator<Students> it = list.iterator();
while(it.hasNext()){
index++;
Students cash = it.next();
int num2 = parameters.length;
HSSFRow row = sheet.createRow(index+1);
initCells(style, num2,cash, parameters,row);
}
}
//驗(yàn)證是否為中文
public boolean checkChinese(String s){
int n=0;
boolean flag =false;
for(int i=0; i<s.length(); i++) {
n = (int)s.charAt(i);
flag=(19968 <= n && n <40623)?true:false;
}
return flag;
}
//將數(shù)據(jù)設(shè)置到excel表格內(nèi)
public void initCells(HSSFCellStyle style, int columnNum, Students t,
String[] endContent, HSSFRow row3) {
for(int j=0;j<columnNum;j++){
HSSFCell cell = row3.createCell(j);
String fieldName = endContent[j];
try{
if(fieldName!="" && !checkChinese(fieldName)){
String getMethodName = "get" +fieldName.substring(0,1).toUpperCase()+fieldName.substring(1);
Class clazz = t.getClass();
Method getMethod = clazz.getMethod(getMethodName, new Class[]{});
String value = (String)getMethod.invoke(t, new Object[]{});
cell.setCellValue(value);
}else{
cell.setCellValue(fieldName);
}
cell.setCellStyle(style);
}catch(Exception e){
e.printStackTrace();
}
}
}
public void createEnd(HSSFSheet sheet,HSSFCellStyle style,int numText,int columnNum,Students t,String[] endContent){
HSSFRow row3 = sheet.createRow(numText+2);
initCells(style, columnNum, t, endContent, row3);
}
//根據(jù)service查詢到的數(shù)據(jù),創(chuàng)建excel表并插入查詢的數(shù)據(jù)信息
protected String getOutputName(List<Students> list, String path, String[] title, String[] parameters, Students t, String[] endContent)
throws IOException{
//根據(jù)傳入的title數(shù)組的第一個(gè)值,設(shè)置文件名稱
String filename = title[0]+"_"+ new SimpleDateFormat("yyyyMMdd").format(new Date())+".xls";
//輸出流放到文件的本地位置
FileOutputStream fos = new FileOutputStream(path+separator+filename);
//列數(shù),根據(jù)title的個(gè)數(shù),除去第一個(gè)就是每列title的信息
int columnNum = title.length-1;
int numText = list.size();
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
sheet.setDefaultColumnWidth (20);
sheet.setDefaultRowHeight((short)400);
HSSFCellStyle contentStyle = this.getPublicStyle(workbook,"");
HSSFCellStyle titleStyle = this.getPublicStyle(workbook,"title");
HSSFCellStyle headerStyle = this.getPublicStyle(workbook,"head");
createHead(sheet,headerStyle,title);
createTitle(sheet,titleStyle,title,columnNum);
createContent(sheet,contentStyle,list,columnNum,parameters);
//createEnd(sheet,contentStyle,numText,columnNum,t,endContent);
workbook.write(fos);
fos.flush();
fos.close();
return filename;
}
}
HandleExcelController用來(lái)處理前端請(qǐng)求,代碼如下:
package cn.wangze.controller;
import java.io.File;
import java.util.List;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import cn.wangze.domain.Students;
import cn.wangze.service.BaseExcelService;
@Controller
@RequestMapping("/File")
public class HandleExcelController extends BaseExcelController{
@Autowired
private BaseExcelService baseExcelService;
@RequestMapping("/UploadExcel")
public void UploadExcel(MultipartFile file,HttpSession session,HttpServletResponse response) throws Exception{
//如果上傳的文件不存在,拋出異常
if(file == null){
throw new Exception("文件不存在");
}
//獲取文件名
String fileName = file.getOriginalFilename();
//選擇上傳的文件存放到項(xiàng)目的路徑
String path = session.getServletContext().getRealPath(separator+"res"+separator+"upload");
if(!checkPathName(fileName,response)) return ;
String msg = baseExcelService.loadExcel(getSheet(file, path, fileName));
sendMsg(true,msg,response);
}
@RequestMapping("/DownLoadExcel")
public void UpdownExcel(Students student,HttpServletResponse res,HttpSession session,HttpServletResponse response)
throws Exception{
List<Students> stus = baseExcelService.queryList(student);
if(stus.size()==0){
res.sendRedirect("/index.jsp");
return;
}
//下載的excel文件存放的本地路徑
String path = session.getServletContext().getRealPath(separator+"res"+separator+"exportExcel"+separator);
ServletOutputStream os = res.getOutputStream();
Students t = baseExcelService.queryTotal(student);
//標(biāo)題文字,數(shù)值中的第一個(gè)值+當(dāng)前日期為文件名稱,以后的每個(gè)元素為每列的標(biāo)題
String[] title={"studets04","id","名字","年齡","性別"};//標(biāo)題文字
//對(duì)應(yīng)實(shí)體類的屬性值
String[] parameters ={"id","name","age","sex"};
String[] endContent = {"","","",""};
//調(diào)用父類的處理方法,生成excel文件
String filename = getOutputName(stus,path,title,parameters,t,endContent);
try {
res.reset();
res.setCharacterEncoding("utf8");
res.setContentType("application/vnd.ms-excel;charset=utf8");
res.setHeader("Content-Disposition", "attachment;fileName="
+new String(filename.getBytes("utf-8"),"iso-8859-1"));
os.write(FileUtils.readFileToByteArray(new File(path+separator+filename)));
sendResult(true,response);
os.flush();
} finally {
if (os != null) {
os.close();
}
}
}
}
2)、service層的處理,把StudentsMapper注入到BaseExcelService
BaseExcelService代碼:
package cn.wangze.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpSession;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.wangze.domain.Students;
import cn.wangze.mapper.StudentsMapper;
@Service
public class BaseExcelService {
@Autowired
private StudentsMapper<Students> studentsMapper;
//判斷字符串是否為空
public boolean isEmpty(String str) {
return str == null || str.length() == 0;
}
//獲取單個(gè)表格(字段)存放的信息
private String getValue(Cell cell,String cellLable,Map<String,String> errMap){
cell.setCellType(Cell.CELL_TYPE_STRING);
String value = cell.getStringCellValue().trim();
return value;
}
//通過(guò)這個(gè)方法將excel表的每行的數(shù)據(jù)放到info對(duì)象里面
private String addInfo(Row row,Students info){
Map<String,String> errMap = new HashMap<String,String>();
String id = getValue(row.getCell(0),"ID",errMap);
String username = getValue(row.getCell(1),"姓名",errMap);
String age = getValue(row.getCell(2),"年齡",errMap);
String sex = getValue(row.getCell(3),"性別",errMap);
String errMsg = errMap.get("errMsg");
if(!isEmpty(errMsg)){
return errMsg;
}
info.setId(id);
info.setName(username);
info.setAge(age);
info.setSex(sex);
return null;
}
public String loadExcel(Sheet sheet) throws Exception{
//新建一個(gè)List集合,用來(lái)存放所有行信息,即每行為單條實(shí)體信息
List<Students> infos = new ArrayList<Students>();
//獲取到數(shù)據(jù)行數(shù),第一行是title,不需要存入數(shù)據(jù)庫(kù),所以rowNum從1開(kāi)始
for (int rowNum = 1; rowNum <= sheet.getLastRowNum(); rowNum++) {
Students info = new Students();
String errMsg2 = addInfo(sheet.getRow(rowNum),info);
if(errMsg2 != null) return errMsg2;
infos.add(info);
}
if(infos.isEmpty()){
return "沒(méi)有解析到學(xué)生數(shù)據(jù),請(qǐng)查驗(yàn)EXCEL文件";
}
//通過(guò)studentsMapper的insertSheetData方法,將實(shí)體類存放的數(shù)據(jù)插入到數(shù)據(jù)庫(kù)
int result = studentsMapper.insertSheetData(infos);
//若插入成功會(huì)返回大于1的整數(shù),返回success
if(result >= 1){
return "success";
}
return "error";
}
//查詢所有數(shù)據(jù)庫(kù)存放的學(xué)生信息
public List<Students> queryList(Students students){
return studentsMapper.queryList(students);
}
//獲取到的學(xué)生實(shí)體信息
public Students queryTotal(Students students){
return studentsMapper.queryTotal(students);
}
public void downExcel(HttpSession session,String separator){
}
}
3)、實(shí)體層的處理,字段要對(duì)應(yīng)excel表的字段
package cn.wangze.domain;
public class Students {
String id;
String name;
String age;
String sex;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}
4)、dao層處理:StudentsMapper.java是一個(gè)接口,業(yè)務(wù)到數(shù)據(jù)庫(kù)需要執(zhí)行的方法在這里聲明,StudentsMapper.xml相當(dāng)于接口的實(shí)現(xiàn)類,用來(lái)連接java和數(shù)據(jù)庫(kù)的操作。
StudentsMapper.java代碼:
package cn.wangze.mapper;
import java.util.List;
public interface StudentsMapper<T> {
public int insertSheetData(List<T> list);
public List<T> queryList(T t);
public T queryTotal(T t);
}
StudentsMapper.xml代碼:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wangze.mapper.StudentsMapper">
<sql id="ColumnList">
id,name,age,sex
</sql>
<sql id="ColumnList_t" >
t.id,t.name,t.age,t.sex
</sql>
<sql id="ValueList">
#{id},#{name},#{age},#{sex}
</sql>
<sql id="WhereClause">
where 1=1
<if test="id!=null and id!=''">and id=#{id}</if>
<if test="name!=null and name!=''">and name=#{name}</if>
<if test="age!=null and age!=''">and age=#{age}</if>
<if test="sex!=null and sex!=''">and sex=#{sex}</if>
</sql>
<sql id="WhereClause_pager" >
where 1=1
<if test="t.id!=null and t.id!=''">and id=#{t.id}</if>
<if test="t.name!=null and t.name!=''">and name=#{t.name}</if>
<if test="t.age!=null">and age=#{t.age}</if>
<if test="t.sex!=null and t.sex!=''">and sex=#{t.sex}</if>
</sql>
<sql id="SetClause" >
set
<trim suffixOverrides="," >
<if test="id!=null">id=#{id},</if>
<if test="name!=null">name=#{name},</if>
<if test="pid!=null">age=#{age},</if>
<if test="url!=null">sex=#{sex},</if>
</trim>
</sql>
<select id="queryList" resultType="Students">
select <include refid="ColumnList"/> from students
</select>
<select id="queryTotal" parameterType="Students" resultType="Students">
select <include refid="ColumnList" /> from students <include refid="WhereClause"/>
<!-- (select <include refid="ColumnList"/> from t_account_cash t
<include refid="WhereClauseQuery"/> group by to_char(t.add_time,'yyyy-mm-dd'),t.account_id) a -->
</select>
<insert id="insertSheetData" useGeneratedKeys="true" parameterType="java.util.List">
<!-- <selectKey resultType="long" keyProperty="id" order="AFTER">
SELECT
LAST_INSERT_ID()
</selectKey> -->
insert into students (id,name,age,sex)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id},#{item.name},#{item.age},#{item.sex})
</foreach>
</insert>
</mapper>
所有的代碼就是這些了,操作的時(shí)候需要注意的多是路徑的問(wèn)題。最復(fù)雜的就是BaseExcelController的操作,它做的事情就是解析上傳和創(chuàng)建下載excel文件。
執(zhí)行完之后的結(jié)果圖是這樣:
在數(shù)據(jù)庫(kù)查看上傳的excel表:

下載到D:\tomcat\tomcat6.0.32\webapps\ExcelHandleDemo\res\exportExcel文件夾下的excel表:

這里有一點(diǎn)不足的地方,我相信你已經(jīng)發(fā)現(xiàn)了,就是下載完excel表格之后,前端還沒(méi)有和業(yè)務(wù)對(duì)接上,沒(méi)有相應(yīng)的提示來(lái)告訴操作人執(zhí)行結(jié)果,只能通過(guò)代碼設(shè)置好的路徑去查看文件夾下是否有下載的excel文件,
不過(guò)這都是細(xì)節(jié)問(wèn)題,相信難不倒聰明的各位。
總結(jié)
以上所述是小編給大家介紹的Java對(duì)Excel表格的上傳和下載處理方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的!
相關(guān)文章
java中的export方法實(shí)現(xiàn)導(dǎo)出excel文件
這篇文章主要介紹了java中的export方法實(shí)現(xiàn)導(dǎo)出excel文件,文章圍繞java導(dǎo)出excel文件的相關(guān)資料展開(kāi)詳細(xì)內(nèi)容,需要的小伙伴可以參考一下2022-03-03
基于Java實(shí)現(xiàn)修改圖片分辨率示例代碼
這篇文章主要介紹了一個(gè)可以修改圖片分辨率的java工具類,文中的示例代碼講解詳細(xì),對(duì)學(xué)習(xí)JAVA有一定的幫助,感興趣的小伙伴快來(lái)跟隨小編一起學(xué)習(xí)吧2021-12-12
Java實(shí)現(xiàn)手寫(xiě)乞丐版線程池的示例代碼
在這篇文章當(dāng)中我們主要介紹實(shí)現(xiàn)一個(gè)非常簡(jiǎn)易版的線程池,深入的去理解其中的原理,麻雀雖小,五臟俱全,感興趣的小伙伴快跟隨小編一起學(xué)習(xí)學(xué)習(xí)吧2022-10-10
JAVA熔斷和降級(jí)真實(shí)關(guān)系的圖文詳解
這篇文章主要介紹了Java熔斷和降級(jí)的關(guān)系,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-09-09
應(yīng)用Java泛型和反射導(dǎo)出CSV文件的方法
這篇文章主要介紹了應(yīng)用Java泛型和反射導(dǎo)出CSV文件的方法,通過(guò)一個(gè)自定義函數(shù)結(jié)合泛型與反射的應(yīng)用實(shí)現(xiàn)導(dǎo)出CSV文件的功能,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-12-12
MapStruct實(shí)體間轉(zhuǎn)換的簡(jiǎn)單用法
今天小編就為大家分享一篇關(guān)于MapStruct實(shí)體間轉(zhuǎn)換的簡(jiǎn)單用法,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2019-03-03

