首先我们先不引入echarts,先简单展现数据库数据
这涉及到三个文件,
TestController.java
package com.example.appledemo.controller;
import com.example.appledemo.mapper.AppleMapper;
import com.example.appledemo.mapper.UserMapper;
import com.example.appledemo.pojo.Apple;
import com.example.appledemo.pojo.User;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@Controller
public class TestController {
@Resource
UserMapper userMapper;
@Resource
AppleMapper appleMapper;
@RequestMapping("/test")
public String test(Model model){
List<Apple> apple = appleMapper.findAll();
model.addAttribute("apple",apple);
mo