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传进去,不然会报空文件异常,

相关推荐
v***91301 小时前
Spring boot创建时常用的依赖
java·spring boot·后端
mCell1 小时前
使用 useSearchParams 同步 URL 和查询参数
前端·javascript·react.js
mCell3 小时前
前端路由详解:Hash vs History
前端·javascript·vue-router
海上彼尚3 小时前
无需绑卡的海外地图
前端·javascript·vue.js·node.js
1024肥宅3 小时前
手写 call、apply、bind 的实现
前端·javascript·ecmascript 6
科杰智能制造4 小时前
纯前端html、js实现人脸检测和表情检测,可直接在浏览器使用
前端·javascript·html
每天吃饭的羊4 小时前
组件库的有些点击事件是name-click这是如何分装de
前端·javascript·vue.js
Coder-coco4 小时前
个人健康管理|基于springboot+vue+个人健康管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·mysql·论文
b***65324 小时前
springboot整合mybatis-plus(保姆教学) 及搭建项目
spring boot·后端·mybatis
5***E6854 小时前
Spring Boot与MyBatis
spring boot·后端·mybatis