Springboot通过前端发起请求,上传excel文件解析数据 postman进行操作

springboot版本3.2.0,数据库版本8

mybatisplus版本3.5.4.1

controller层
java 复制代码
    @PostMapping("/import")
    @ResponseBody
    public List<User> excelUpload( MultipartFile file) throws IOException{
        if (file==null){
            System.out.println("文件为空");
        }
      List<User> userList= EasyExcel.read(file.getInputStream(), User.class,new UserUploadListener(userService))
              .head(User.class)
               .sheet()
               .doReadSync();
        System.out.println(userList);
       return userList;
    }
测试结果
后端返回数据

Postman返回数据
注意

使用postman进行测试时,需要把key传进去,不然会报空文件异常,

相关推荐
梓仁沐白6 分钟前
CSAPP-Attacklab
前端
是席木木啊10 分钟前
Spring Boot 中 @Async 与 @Transactional 结合使用全解析:避坑指南
数据库·spring boot·oracle
阿拉斯攀登10 分钟前
自定义 Spring Boot 自动配置
java·spring boot
郑州光合科技余经理22 分钟前
海外国际版同城服务系统开发:PHP技术栈
java·大数据·开发语言·前端·人工智能·架构·php
appearappear33 分钟前
Mac 上重新安装了Cursor 2.2.30,重新配置 springboot 过程记录
java·spring boot·后端
一行注释35 分钟前
前端数据加密:保护用户数据的第一道防线
前端
纪伊路上盛名在41 分钟前
记1次BioPython Entrez模块Elink的debug
前端·数据库·python·debug·工具开发
xiaoxue..42 分钟前
React 之 Hooks
前端·javascript·react.js·面试·前端框架
旧梦吟1 小时前
脚本网页 三人四字棋
前端·数据库·算法·css3·html5
莫物1 小时前
element el-table表格 添加唯一标识
前端·javascript·vue.js