一、项目环境
- IDEA2019.3.3
- MySql 5.7
- SSM
- echarts.js
文章图片
2.后台准备 book实体类:
public class Book {
private Integer bid;
private String bname;
private String btype;
private Integer bnumber;
public Book(Integer bid, String bname, String btype, Integer bnumber) {
this.bid = bid;
this.bname = bname;
this.btype = btype;
this.bnumber = bnumber;
}public Book() {
super();
}public Integer getBid() {
return bid;
}public void setBid(Integer bid) {
this.bid = bid;
}public String getBname() {
return bname;
}public void setBname(String bname) {
this.bname = bname;
}public String getBtype() {
return btype;
}public void setBtype(String btype) {
this.btype = btype;
}public Integer getBnumber() {
return bnumber;
}public void setBnumber(Integer bnumber) {
this.bnumber = bnumber;
}
}
mapper层:
@Repository
public interface BookMapper {
List selectAll();
}
service层:
public interface IBookService {
List selectAll();
}
【Echarts|Echarts连接数据库使用Ajax的简单使用】service实现类:
@Service
public class BookServiceImpl implements IBookService {
@Autowired
private BookMapper bookMapper;
@Override
public List selectAll() {
return bookMapper.selectAll();
}
}
mapper映射文件:
bid, bname, btype, bnumberselect * from book
Controller层:
@Controller
public class IndexController {@Autowired
private IBookService bookService;
@RequestMapping("/All")
public String toAll(){
return "echarts";
}@RequestMapping("/getAll")
@ResponseBody
public List selectAll(){
List books = bookService.selectAll();
System.out.println("books"+books);
return books;
};
}
三、前台页面
ECharts - 锐客网
效果:
文章图片
博主水平有限,难免有错。欢迎评论交流
推荐阅读
- Vue|Vue介绍与入门(一篇就可入门)
- JDK1.8新特性|JDK1.8新特性之Lambda表达式
- Java_JVM|GC问题记录 – DirectByteBuffer
- 开发语言|java会议OA系统(一)
- java|gitlab入门_作为GitLab贡献者入门
- python|zip和imap的结合
- 【JAVA并发编程】ThreadPoolExecutor的源码解读
- JavaWeb|JavaScript(8)深入理解作用域
- 前端|【前端三剑客二】CSS手术刀剖析第一篇