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

相关推荐
悟空瞎说3 分钟前
Electron 踩坑实录:主窗口 icon 配置了,打包 Windows 后死活不显示?(全网最细排查+解决方案)
前端
编程小风筝5 分钟前
如何用redission实现springboot的分布式锁?
spring boot·分布式·后端
码喽7号16 分钟前
Springboot学习六:MybatisPlus的多表查询以及分页查询
java·spring boot·学习
Lee川24 分钟前
Vue Router 4 核心精讲:从原理到面试实战
前端·vue.js
树上有只程序猿27 分钟前
2026年,学“前端”还有前途吗?
前端
我命由我1234532 分钟前
JS 开发问题:url.includes is not a function
开发语言·前端·javascript·html·ecmascript·html5·js
不吃香菜学java36 分钟前
苍穹外卖-新增菜品需求分析
java·spring boot·spring·tomcat·maven·ssm
weixin1997010801637 分钟前
义乌购商品详情页前端性能优化实战
前端·性能优化
汪啊汪40 分钟前
Day 3:Hooks 原理
前端
汪啊汪42 分钟前
Day 2:JSX 转换原理
前端