Spirngboot+mybatis+poi+echart实现数据可视化

本文介绍了如何使用Springboot、Mybatis、POI和Echarts来实现数据可视化。通过配置FileUpload、ObjectExcelRead、ObjectExcelView和PageData类,完成文件上传、数据导出及数据查询。在application.yml中配置相关设置,并在HTML页面通过Ajax请求后台数据,将数据渲染到Echarts图表中。
摘要由CSDN通过智能技术生成

不多说了 首先滤清思路

这是一套正常的curd架构(这里由于浪费时间所以我只写了新增其他代码用mp就能随便写)

注意 本篇文章最重要的

就是这四个配置类 (结束后会放在最后)

FileUpload用于指定用户文件upload的服务器指定位置

ObjectExcelRead用于导出功能

ObjectExcelView用于做导出功能

PageData用于查出数据

application.yml的配置

server:
  port: 80
spring:
  thymeleaf:
    cache: false                   # 这个开发配置为false,避免改了模板还要重启服务器
    prefix: classpath:/templates/  #模板文件视图前缀,默认是classpath:/templates/,可不用配置
    suffix: .html
  mvc:
    view:
      suffix: .html
      prefix:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/spring?serverTimezone=UTC
    username: root
    password: xjy
mybatis-plus:
  global-config:
    db-config:
      id-type: auto
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

在resource的资源加入

html显示数据要用

然后编写Controller类

@Controller
@RequestMapping("/goods")
public class goodsController {

    @Autowired
    private GoodsService goodsService;

    @RequestMapping("/excel")
    public ModelAndView exportExcel() {
        ModelAndView mv = new ModelAndView();
        try {
            Map<String, Object> dataMap = new HashMap<>();
            List<String> titles = new ArrayList<>();
            titles.add("商品编号"); // 1
            titles.add("名称"); // 2
            titles.add("数量");//3
            dataMap.put("titles", titles);
            List<Goods> varOList = goodsService.queryAllExcel();
            List<PageData> varList = new ArrayList<>();
            for (int i = 0; i < varOList.size(); i++) {
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值