java 如何上传excel文件大小_java中excel文件的导入,限制上传的文件类型,文件的大小,显示上传文件的进度条...

1. 前台代码

导入excel测试 请选择你要导入的excel文件(.xls;.xlsx)    //进度条框
//上传了多少百分比 0% 导入

2. 后台spring代码

package com.bjpowernode.excel.importExcel.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import java.util.HashMap; import java.util.Map; /** * ClassName:ImportExcel * Package:com.bjpowernode.excel.importExcel.controller * Description: * * @Date:2019/2/25 21:46 * @Author: 郑军 */ @Controller public class ImportExcel { @RequestMapping("/") public String toIndex() { return "index"; } @RequestMapping("/importExcel") @ResponseBody public Map importExcel(@RequestParam("file") MultipartFile file) { Map map = new HashMap<>(); String originalFilename = file.getOriginalFilename(); String fileType = originalFilename.substring(originalFilename.lastIndexOf(".")); if (!".xls".equals(fileType) && !".xlsx".equals(fileType)) { map.put("result", false); map.put("errorMessage", "导入的文件类型有误"); return map; } // 导入的excel数据相关的业务逻辑校验,暂时省略。 map.put("result", true); map.put("errorMessage", ""); return map; } }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值