(一)文件后缀问题:

获取文件名:

String name = multipartFile.getOriginalFilename();

获取后缀,文件类型,小写:

String postFix = FileUtil.extName(name).toLowerCase();

判断是否为图片格式:

public static boolean isImage(String extName) {String imgs[] = { "bmp", "jpg", "jpeg", "png", "tiff", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd","cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "wmf" };return ArrayUtil.containsIgnoreCase(imgs, extName);}

其他格式 可以类推。

(二)图片获取传入前台:

这里我传入的是文件流:

  @RequestMapping(method = RequestMethod.GET, value = "/getStorageImage")public void getStorageImage(HttpServletRequest request, HttpServletResponse response, String id) throws IOException {ValidateUtil.isNotBlank(id, "文件编号非法,找不到对应文件");OutputStream stream = null;TaskPhotoSd taskPhotoSd = taskPhotoSdService.selectById(id);try {if (taskPhotoSd != null) {FastDfsFile fastDfsFile = new FastDfsFile();String fileType = StrUtil.subAfter(taskPhotoSd.getStoragePath(), ".", false);fastDfsFile.setRemoteFileUrl(StrUtil.subAfter(taskPhotoSd.getStoragePath(), "/", false));fastDfsFile.setGroupName(StrUtil.subBefore(taskPhotoSd.getStoragePath(), "/", false));byte[] img = fastDfsUtil.downloadFile(fastDfsFile);response.addHeader("Content-Disposition", "attachment;filename=" + new String((taskPhotoSd.getPhotoNmae() + "." + fileType).getBytes("GBK"), "ISO8859_1"));response.addHeader("Content-Length", "" + img.length);response.setContentType("image/jpg");stream = new BufferedOutputStream(response.getOutputStream());stream.write(img);stream.flush();} else {throw new ValidateException("未找到");}} catch (Exception e) {throw e;} finally {FortifyUtil.close(stream);}}

这里我使用的是fastdfs工具类下载的文件,byte数组获取内容,根据url路径,可以按照不同的方法来获取。

其中上面的代码是浏览器会自动下载,如果要进行预览操作,可以将response.addHeader方法进行注释。

(三)excel文件导出:

 @SystemControllerLog(desc="导出")@RequestMapping(method=RequestMethod.GET, value = "exportProject")public void exportProject(Project project, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {try {String fileName = "项目数据"+DateUtil.now()+".xlsx";List<ProjectExcel> projects = projectService.exportGetData();new ExcelExport("项目数据", ProjectExcel.class).setDataList(projects).write(response, fileName).dispose();} catch (Exception e) {renderResult(response, RestResultGenerator.success("导出项目失败!失败信息:"+e.getMessage()));}}

ExcelExport文件如下:

package com.glens.common.excel;import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import javax.servlet.http.HttpServletResponse;import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Comment;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;import com.glens.common.excel.ExcelField.Align;
import com.glens.common.excel.ExcelField.Type;
import com.glens.common.exception.ExcelException;
import com.glens.common.util.FortifyUtil;/*** 导出Excel文件(导出“XLSX”格式,支持大数据量导出 )
*
* @ClassName: ExcelExport
* @Description: TODO(这里用一句话描述这个类的作用)
* @author XuBing
* @date 2018年3月13日 下午4:37:01*/
public class ExcelExport {private static final Logger logger = LoggerFactory.getLogger(ExcelExport.class);/*** 工作薄对象*/private Workbook wb;/*** 工作表对象*/private Sheet sheet;/*** 样式列表*/private Map<String, CellStyle> styles;/*** 当前行号*/private int rownum;/*** 注解列表(Object[]{ ExcelField, Field/Method })*/List<Object[]> annotationList;/*** 构造函数* @param title 表格标题,传“空值”,表示无标题* @param cls 实体对象,通过annotation.ExportField获取标题* @param type 导出类型(1:导出数据)*/public ExcelExport(String title, Class<?> cls){this(title, cls, Type.EXPORT);}/*** 构造函数* @param title 表格标题,传“空值”,表示无标题* @param cls 实体对象,通过annotation.ExportField获取标题* @param type 导出类型(1:导出数据;2:导出模板)* @param groups 导入分组*/public ExcelExport(String title, Class<?> cls, Type type, String... groups){this(null, title, cls, type, groups);}/*** 构造函数* @param wb 工作簿对象,支持多个Sheet,通过ExcelExport.createWorkbook()创建* @param sheetName,指定Sheet名称* @param title 表格标题,传“空值”,表示无标题* @param cls 实体对象,通过annotation.ExportField获取标题* @param type 导出类型(1:导出数据;2:导出模板)* @param groups 导入分组*/public ExcelExport(Workbook wb, String title, Class<?> cls, Type type, String... groups){if (wb != null){this.wb = wb;}else{this.wb = createWorkbook();}this.createSheet(null, title, cls, type, groups);}/*** 构造函数* @param title 表格标题,传“空值”,表示无标题* @param headerList 表头数组*/public ExcelExport(String title, List<String> headerList) {this(null, null, title, headerList);}/*** 构造函数* @param wb 工作簿对象,支持多个Sheet,通过ExcelExport.createWorkbook()创建* @param sheetName,指定Sheet名称* @param title 表格标题,传“空值”,表示无标题* @param headerList 表头列表*/public ExcelExport(Workbook wb, String sheetName, String title, List<String> headerList) {if (wb != null){this.wb = wb;}else{this.wb = createWorkbook();}this.createSheet(sheetName, title, headerList, null);}/*** 创建一个工作簿*/private Workbook createWorkbook(){return new SXSSFWorkbook(500);}/*** 创建工作表* @param sheetName,指定Sheet名称* @param title 表格标题,传“空值”,表示无标题* @param cls 实体对象,通过annotation.ExportField获取标题* @param type 导出类型(1:导出数据;2:导出模板)* @param groups 导入分组*/public void createSheet(String sheetName, String title, Class<?> cls, Type type, String... groups){this.annotationList = CollUtil.newArrayList();// Get annotation fieldField[] fs = cls.getDeclaredFields();for (Field f : fs){ExcelFields efs = f.getAnnotation(ExcelFields.class);if (efs != null && efs.value() != null){for (ExcelField ef : efs.value()){addAnnotation(annotationList, ef, f, type, groups);}}ExcelField ef = f.getAnnotation(ExcelField.class);addAnnotation(annotationList, ef, f, type, groups);}// Get annotation methodMethod[] ms = cls.getDeclaredMethods();for (Method m : ms){ExcelFields efs = m.getAnnotation(ExcelFields.class);if (efs != null && efs.value() != null){for (ExcelField ef : efs.value()){addAnnotation(annotationList, ef, m, type, groups);}}ExcelField ef = m.getAnnotation(ExcelField.class);addAnnotation(annotationList, ef, m, type, groups);}// Field sortingCollections.sort(annotationList, new Comparator<Object[]>() {@Overridepublic int compare(Object[] o1, Object[] o2) {return new Integer(((ExcelField)o1[0]).sort()).compareTo(new Integer(((ExcelField)o2[0]).sort()));};});// InitializeList<String> headerList = CollUtil.newArrayList();List<Integer> headerWidthList = CollUtil.newArrayList();for (Object[] os : annotationList){ExcelField ef = (ExcelField)os[0];String headerTitle = ef.title();// 如果是导出,则去掉注释if (type == Type.EXPORT){String[] ss = Convert.toStrArray(StrUtil.splitTrim(headerTitle,"**", 2));if (ss.length == 2){headerTitle = ss[0];}}headerList.add(headerTitle);headerWidthList.add(ef.width());}// 创建工作表this.createSheet(sheetName, title, headerList, headerWidthList);}/*** 添加到 annotationList*/private void addAnnotation(List<Object[]> annotationList, ExcelField ef, Object fOrM, Type type, String... groups){
//      if (ef != null && (ef.type()==0 || ef.type()==type)){if (ef != null && (ef.type() == Type.ALL || ef.type() == type)){if (groups != null && groups.length > 0){boolean inGroup = false;for (String g : groups){if (inGroup){break;}for (String efg : ef.groups()){if (StrUtil.equals(g, efg)){inGroup = true;annotationList.add(new Object[]{ef, fOrM});break;}}}}else{annotationList.add(new Object[]{ef, fOrM});}}}/*** 创建工作表* @param sheetName,指定Sheet名称* @param title 表格标题,传“空值”,表示无标题* @param cls 实体对象,通过annotation.ExportField获取标题* @param type 导出类型(1:导出数据;2:导出模板)* @param groups 导入分组*/public void createSheet(String sheetName, String title, List<String> headerList, List<Integer> headerWidthList) {this.sheet = wb.createSheet(Convert.toStr(sheetName, Convert.toStr(title, "Sheet1")));this.styles = createStyles(wb);// Create titleif (StrUtil.isNotBlank(title)){Row titleRow = sheet.createRow(rownum++);titleRow.setHeightInPoints(30);Cell titleCell = titleRow.createCell(0);titleCell.setCellStyle(styles.get("title"));titleCell.setCellValue(title);sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),titleRow.getRowNum(), titleRow.getRowNum(), headerList.size()-1));}// Create headerif (headerList == null){throw new ExcelException("headerList not null!");}Row headerRow = sheet.createRow(rownum++);headerRow.setHeightInPoints(16);for (int i = 0; i < headerList.size(); i++) {Cell cell = headerRow.createCell(i);cell.setCellStyle(styles.get("header"));String[] ss =Convert.toStrArray(StrUtil.splitTrim(headerList.get(i), "**", 2));if (ss.length==2){cell.setCellValue(ss[0]);Comment comment = this.sheet.createDrawingPatriarch().createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));comment.setRow(cell.getRowIndex());comment.setColumn(cell.getColumnIndex());comment.setString(new XSSFRichTextString(ss[1]));cell.setCellComment(comment);}else{cell.setCellValue(headerList.get(i));}
//          sheet.autoSizeColumn(i);}boolean isDefWidth = (headerWidthList != null && headerWidthList.size() == headerList.size());for (int i = 0; i < headerList.size(); i++) {int colWidth = -1;if (isDefWidth){colWidth = headerWidthList.get(i);}if (colWidth == -1){colWidth = sheet.getColumnWidth(i)*2;colWidth = colWidth < 3000 ? 3000 : colWidth;}if (colWidth == 0){sheet.setColumnHidden(i, true);}else{sheet.setColumnWidth(i, colWidth);  }}logger.debug("Create sheet {0} success.", sheetName);}//   /**
//   * 构造函数
//   * @param title 表格标题,传“空值”,表示无标题
//   * @param headers 表头数组
//   */
//  public ExcelExport(String title, List<String> headerList) {
//      this(null, null, title, headerList);
//  }
//
//  /**
//   * 构造函数
//   * @param wb 工作簿对象,支持多个Sheet,通过ExcelExport.createWorkbook()创建
//   * @param sheetName,指定Sheet名称
//   * @param title 表格标题,传“空值”,表示无标题
//   * @param headerList 表头列表
//   */
//  public ExcelExport(Workbook wb, String sheetName, String title, List<String> headerList) {
//      initialize(wb, sheetName, title, headerList, null);
//  }/*** 创建表格样式* @param wb 工作薄对象* @return 样式列表*/private Map<String, CellStyle> createStyles(Workbook wb) {Map<String, CellStyle> styles = new HashMap<String, CellStyle>();CellStyle style = wb.createCellStyle();style.setAlignment(HorizontalAlignment.CENTER);style.setVerticalAlignment(VerticalAlignment.CENTER);Font titleFont = wb.createFont();titleFont.setFontName("Arial");titleFont.setFontHeightInPoints((short) 16);titleFont.setBold(true);style.setFont(titleFont);styles.put("title", style);style = wb.createCellStyle();style.setVerticalAlignment(VerticalAlignment.CENTER);style.setBorderRight(BorderStyle.THIN);style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());style.setBorderLeft(BorderStyle.THIN);style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());style.setBorderTop(BorderStyle.THIN);style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());style.setBorderBottom(BorderStyle.THIN);style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());Font dataFont = wb.createFont();dataFont.setFontName("Arial");dataFont.setFontHeightInPoints((short) 10);style.setFont(dataFont);styles.put("data", style);style = wb.createCellStyle();style.cloneStyleFrom(styles.get("data"));style.setAlignment(HorizontalAlignment.LEFT);styles.put("data1", style);style = wb.createCellStyle();style.cloneStyleFrom(styles.get("data"));style.setAlignment(HorizontalAlignment.CENTER);styles.put("data2", style);style = wb.createCellStyle();style.cloneStyleFrom(styles.get("data"));style.setAlignment(HorizontalAlignment.RIGHT);styles.put("data3", style);style = wb.createCellStyle();style.cloneStyleFrom(styles.get("data"));
//      style.setWrapText(true);style.setAlignment(HorizontalAlignment.CENTER);style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());style.setFillPattern(FillPatternType.SOLID_FOREGROUND);Font headerFont = wb.createFont();headerFont.setFontName("Arial");headerFont.setFontHeightInPoints((short) 10);headerFont.setBold(true);headerFont.setColor(IndexedColors.WHITE.getIndex());style.setFont(headerFont);styles.put("header", style);return styles;}/*** 添加一行* @return 行对象*/public Row addRow(){return sheet.createRow(rownum++);}/*** 添加一个单元格* @param row 添加的行* @param column 添加列号* @param val 添加值* @return 单元格对象*/public Cell addCell(Row row, int column, Object val){return this.addCell(row, column, val, Align.AUTO, Class.class, null);}/*** 添加一个单元格* @param row 添加的行* @param column 添加列号* @param val 添加值* @param align 对齐方式(1:靠左;2:居中;3:靠右)* @param dataFormat 数值格式(例如:0.00,yyyy-MM-dd)* @return 单元格对象*/public Cell addCell(Row row, int column, Object val, Align align, Class<?> fieldType, String dataFormat){Cell cell = row.createCell(column);String defaultDataFormat = "@";try {if(val == null){cell.setCellValue("");}else if(fieldType != Class.class){cell.setCellValue((String)fieldType.getMethod("setValue", Object.class).invoke(null, val));try{defaultDataFormat = (String)fieldType.getMethod("getDataFormat").invoke(null);} catch (Exception ex) {defaultDataFormat = "@";}}else{if(val instanceof String) {cell.setCellValue((String) val);}else if(val instanceof Integer) {cell.setCellValue((Integer) val);defaultDataFormat = "0";}else if(val instanceof Long) {cell.setCellValue((Long) val);defaultDataFormat = "0";}else if(val instanceof Double) {cell.setCellValue((Double) val);defaultDataFormat = "0.00";}else if(val instanceof Float) {cell.setCellValue((Float) val);defaultDataFormat = "0.00";}else if(val instanceof Date) {cell.setCellValue((Date) val);defaultDataFormat = "yyyy-MM-dd HH:mm";}else {cell.setCellValue((String)Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(), "fieldtype."+val.getClass().getSimpleName()+"Type")).getMethod("setValue", Object.class).invoke(null, val));}}
//          if (val != null){CellStyle style = styles.get("data_column_"+column);if (style == null){style = wb.createCellStyle();style.cloneStyleFrom(styles.get("data"+(align.value()>=1&&align.value()<=3?align.value():"")));if (dataFormat != null){defaultDataFormat = dataFormat;}style.setDataFormat(wb.createDataFormat().getFormat(defaultDataFormat));styles.put("data_column_" + column, style);}cell.setCellStyle(style);
//          }} catch (Exception ex) {logger.info("Set cell value [{},{}] error: {}",row.getRowNum(),column, ex.toString());cell.setCellValue(val.toString());}return cell;}/*** 添加数据(通过annotation.ExportField添加数据)* @return list 数据列表*/public <E> ExcelExport setDataList(List<E> list){for (E e : list){int colunm = 0;Row row = this.addRow();StringBuilder sb = new StringBuilder();for (Object[] os : annotationList){ExcelField ef = (ExcelField)os[0];Object val = null;// Get entity valuetry{if (StrUtil.isNotBlank(ef.attrName())){val = ReflectUtil.getFieldValue(e, ef.attrName());}else{if (os[1] instanceof Field){val = ReflectUtil.getFieldValue(e, ((Field)os[1]).getName());}else if (os[1] instanceof Method){val = ReflectUtil.invoke(e, ((Method)os[1]).getName(), new Class[] {}, new Object[] {});}}// If is dict, get dict labelif (StrUtil.isNotBlank(ef.dictType())){Class<?> dictUtils = Class.forName("com.jeesite.modules.sys.utils.DictUtils");val = dictUtils.getMethod("getDictLabel", String.class, String.class,String.class).invoke(null, val==null?"":val.toString(), ef.dictType(), "");//val = DictUtils.getDictLabel(val==null?"":val.toString(), ef.dictType(), "");}}catch(Exception ex) {// Failure to ignorelogger.info(ex.toString());val = "";}String dataFormat = ef.dataFormat();this.addCell(row, colunm++, val, ef.align(), ef.fieldType(), dataFormat);sb.append(val + ", ");}logger.debug("Write success: [{}] {}",row.getRowNum(),sb.toString());}return this;}/*** 输出数据流* @param os 输出数据流*/public ExcelExport write(OutputStream os){try{wb.write(os);}catch(IOException ex){logger.error(ex.getMessage(), ex);} finally{FortifyUtil.close(os);}return this;}/*** 输出到客户端* @param fileName 输出文件名*/public ExcelExport write(HttpServletResponse response, String fileName){response.reset();response.setContentType("application/octet-stream; charset=utf-8");response.setHeader("Content-Disposition", "attachment; filename="+URLUtil.encode(fileName));try {write(response.getOutputStream());} catch (IOException ex) {logger.error(ex.getMessage(), ex);}return this;}/*** 输出到文件* @param fileName 输出文件名*/public ExcelExport writeFile(String name) throws FileNotFoundException{FileOutputStream os = null;try {os = new FileOutputStream(name);this.write(os);} catch (FileNotFoundException e) {throw e;} finally {FortifyUtil.close(os);}return this;}/*** 清理临时文件*/public ExcelExport dispose(){if (wb instanceof SXSSFWorkbook){((SXSSFWorkbook)wb).dispose();}return this;}//   /**
//   * 导出测试
//   */
//  public static void main(String[] args) throws Throwable {
//
//      List<String> headerList = CollUtil.newArrayList();
//      for (int i = 1; i <= 10; i++) {
//          headerList.add("表头"+i);
//      }
//
//      List<String> dataRowList = CollUtil.newArrayList();
//      for (int i = 1; i <= headerList.size(); i++) {
//          dataRowList.add("数据"+i);
//      }
//
//      List<List<String>> dataList = CollUtil.newArrayList();
//      for (int i = 1; i <=100; i++) {
//          dataList.add(dataRowList);
//      }
//
//      ExcelExport ee = new ExcelExport("表格标题", headerList);
//
//      for (int i = 0; i < dataList.size(); i++) {
//          Row row = ee.addRow();
//          for (int j = 0; j < dataList.get(i).size(); j++) {
//              ee.addCell(row, j, dataList.get(i).get(j));
//          }
//      }
//
//      ee.writeFile("target/export.xlsx");
//
//      ee.dispose();
//
//      //log.debug("Export success.");
//
//  }}

ProjectExcel文件:

package com.glens.pwCloud.project.entity;import java.io.Serializable;
import java.math.BigDecimal;import com.glens.common.excel.ExcelField;public class ProjectExcel implements Serializable{/*** */private static final long serialVersionUID = -504439323077191027L;@ExcelField(title="项目名称", type= ExcelField.Type.ALL, sort=1)private String projectName;@ExcelField(title="预算", type= ExcelField.Type.ALL, sort=2)private BigDecimal totalBudget;@ExcelField(title="紧急程度", type= ExcelField.Type.ALL, sort=3)private String emergencyExtName;@ExcelField(title="施工队长", type= ExcelField.Type.ALL, sort=4)private String constructionCaptainName;@ExcelField(title="土建施工队长", type= ExcelField.Type.ALL, sort=5)private String civilConstructionCaptainName;@ExcelField(title="电气安装队长", type= ExcelField.Type.ALL, sort=6)private String electricalInstallCaptainName;@ExcelField(title="物资领料员", type= ExcelField.Type.ALL, sort=7)private String materialPickerName;@ExcelField(title="政处推进员", type= ExcelField.Type.ALL, sort=8)private String politicalOfficePromoterName;@ExcelField(title="资料归档员", type= ExcelField.Type.ALL, sort=9)private String dataFilerName;@ExcelField(title="结算编制员", type= ExcelField.Type.ALL, sort=9)private String settlementCompilerName;@ExcelField(title="设计变更员", type= ExcelField.Type.ALL, sort=9)private String designChangerName;public String getProjectName() {return projectName;}public void setProjectName(String projectName) {this.projectName = projectName;}public BigDecimal getTotalBudget() {return totalBudget;}public void setTotalBudget(BigDecimal totalBudget) {this.totalBudget = totalBudget;}public String getEmergencyExtName() {return emergencyExtName;}public void setEmergencyExtName(String emergencyExtName) {this.emergencyExtName = emergencyExtName;}public String getConstructionCaptainName() {return constructionCaptainName;}public void setConstructionCaptainName(String constructionCaptainName) {this.constructionCaptainName = constructionCaptainName;}public String getCivilConstructionCaptainName() {return civilConstructionCaptainName;}public void setCivilConstructionCaptainName(String civilConstructionCaptainName) {this.civilConstructionCaptainName = civilConstructionCaptainName;}public String getElectricalInstallCaptainName() {return electricalInstallCaptainName;}public void setElectricalInstallCaptainName(String electricalInstallCaptainName) {this.electricalInstallCaptainName = electricalInstallCaptainName;}public String getMaterialPickerName() {return materialPickerName;}public void setMaterialPickerName(String materialPickerName) {this.materialPickerName = materialPickerName;}public String getPoliticalOfficePromoterName() {return politicalOfficePromoterName;}public void setPoliticalOfficePromoterName(String politicalOfficePromoterName) {this.politicalOfficePromoterName = politicalOfficePromoterName;}public String getDataFilerName() {return dataFilerName;}public void setDataFilerName(String dataFilerName) {this.dataFilerName = dataFilerName;}public String getSettlementCompilerName() {return settlementCompilerName;}public void setSettlementCompilerName(String settlementCompilerName) {this.settlementCompilerName = settlementCompilerName;}public String getDesignChangerName() {return designChangerName;}public void setDesignChangerName(String designChangerName) {this.designChangerName = designChangerName;}
}

java后台文件处理相关问题相关推荐

  1. react接收后端文件_React获取Java后台文件流并下载Excel文件流程解析

    记录使用blob对象接收java后台文件流并下载为xlsx格式的详细过程,关键部分代码如下. 首先在java后台中设置response中的参数: public void exportExcel(Htt ...

  2. java文件流下载excel_React获取Java后台文件流下载Excel文件

    记录使用blob对象接收java后台文件流并下载为xlsx格式的详细过程,关键部分代码如下. 首先在java后台中设置response中的参数: public void exportExcel(Htt ...

  3. Java后台文件批量压缩下载

    最近遇到一个需求,要求设计批量下载功能,即点击按钮即可将勾选的文件全部打包成压缩包,批量下载下来. 页面如下,勾选对应的复选框,点击批量下载按钮,即可将复选框对应的附件批量压缩成一个zip压缩包,然后 ...

  4. java mf文件怎么打开_安卓手机如何打开.MF文件?

    01 MF文件是JAR游戏里面的文件,先解压出JAR文件,.MF直接文本打开就行了,非智能可以用MiniCommander(UTF-8编码打开).JAR文件是一种归档文件,以ZIP格式构建,以.jar ...

  5. java源程序文件_.class文件为Java源程序文件

    .class文件为Java源程序文件 更多相关问题 在任何情况下使用视觉信号都能起到遇险报警的作用. <礼记>言,贫贱而知好礼,则().A.不骄纵B.不奢靡C.志不慑D.心怀礼 " ...

  6. 关于使用Java后台导入excel文件,读取数据后,更新数据库,并返回数据给到前端的相关问题总结

    在之前的项目中,使用到了Java后台读取excel文件数据的功能点,本想着该功能点已经做过了,这一类的应该都大差不离,不过在刚结束的一个项目中,现实给我深深的上了一课,特此编写此片博客,以作记录,并给 ...

  7. Java后台相关知识盘点(持续更新中)

    前言 本篇博客 取自于博主工作以来 对一些Java后台开发相关的 基础知识盘点和回顾, 主要涉及到Spring SpringBoot 和MyBatis相关的知识, 未来会一直更新下去- Spring ...

  8. java 加载dll后打包_让Jacob从当前路径读取dll文件及相关打包方法

    让Jacob从当前路径读取dll文件及相关打包方法 独立观察员2013.08.12 Jacob  LibraryLoader.class修改版代码 功能:让jacob可在当前路径下的dll文件夹内读取 ...

  9. 【Android 安全】DEX 加密 ( Java 工具开发 | 解压 apk 文件 | 加密生成 dex 文件 | 打包未签名 apk 文件 | 文件解压缩相关代码 )

    文章目录 一.解压 apk 文件 二.加密生成 dex 文件 三.打包未签名 apk 文件 四.完整代码示例 五.文件解压缩相关代码 六.执行结果 参考博客 : [Android 安全]DEX 加密 ...

最新文章

  1. docker概念:用Dockerfile生成Image
  2. php程序计算偶数和,php怎么编写计算双数的和
  3. Boost:双图bimap与range范围的测试程序
  4. AD20学习笔记5---PCB设计规则设置及PCB手工布线
  5. 女生做一个“程序猿”,真有那么不现实吗?正在学编程的女孩子注意了!
  6. django-视图函数装饰器
  7. Android TextView,EditText要求固定行数自动调整TextSize
  8. pg数据库的基本操作
  9. edm邮件html模板,EDM模板使用说明
  10. Android studio profiler中的Shallow size和retained sizes是什么意思
  11. matlab矩阵特征分解,用MATLAB实现矩阵分解
  12. vue+weui 手机端项目
  13. SpringBoot整合Mybaits开发报java.lang.IllegalArgumentException: At least one base package must be specifie
  14. 2022 AI 岗位风向标
  15. 20 个关于程序员的笑话,看懂了,你就不会笑了,也不会羡慕他们工资高了!...
  16. MemSQL 的安装和简单使用 比Mysql快30倍的关系型数据库
  17. 靠java_基础不牢靠,何以争朝夕?Java基础面试82道详细解析!(一)
  18. respond_to 和 respond_with
  19. DRM标准学习笔记1
  20. Educoder大数据技术与应用作业-郑悦林

热门文章

  1. VScode修改插件安装位置最有效的方法
  2. y510p 安装ubuntu问题解决记录
  3. 嗅探欺骗之Ettercap局域网攻击
  4. 最新云盘网盘程序源码带后台版
  5. 大数据--阿里曾鸣:商业智能化是未来最重要的一个趋势
  6. oracle必须运行netca,【监听配置】Oracle如何静默运行NETCA,使用netca.rsp文件
  7. 关于v-if 和 v-for 同时用在同一个元素上的解决方案
  8. 因提供18禁动漫,毒害未成年人,国内最大动漫网站被重罚
  9. 即时通讯/聊天源码/聊天APP/im/PC/H5/安卓/苹果/开源
  10. 香港十大正规外汇交易平台排名2020版