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

相关推荐
问心无愧05132 分钟前
ctf show web入门27
前端
小村儿17 分钟前
给 AI Agent 装上"长期记忆":Karpathy 的 LLM Wiki 思想,我做成了工具
前端·后端·ai编程
竹林81822 分钟前
用ethers.js连接MetaMask实现Web3钱包登录:从踩坑到稳定运行的完整记录
前端·javascript
heyCHEEMS25 分钟前
如何用 Recast 实现静态配置文件源码级读写
前端·node.js
心连欣26 分钟前
从零开始,学习所有指令!
前端·javascript·vue.js
review4454329 分钟前
大模型和function calling分别是如何工作的
前端
东东同学30 分钟前
耗时一个月,我把 Nuxt 首屏性能排障经验做成了一个 AI Skill
前端·agent
冴羽1 小时前
超越 Vibe Coding —— AI 辅助编程指南
前端·ai编程·vibecoding
梦想的颜色2 小时前
一天一个SKILL——前端最佳自动化测试 webapp-testing
前端·web app
生活真难2 小时前
SpringCloud - 任务调度 - xxl-job-java
java·spring boot·spring cloud