This article example shares the specific code of Vue to implement student management for your reference. The specific content is as follows difficulty
Part of the codeVue.js <script> let app = new Vue({ el:"#app", data:{ currentPage:1, //Current page pageSize:10, //Number of records displayed per page total:0, //Total number of records; list:[], //Current page data //Binding student information student:{ name:"", age:"" } }, methods:{ pager:function(num){ this.currentPage = num; this.getData(); }, getData:function () { axios.post("/StudentManager/showAllServlet?currentPage=" + this.currentPage + "&pageSize=" + this.pageSize).then((resp) => { this.list = resp.data.datas; this.total = resp.data.total; }); }, add:function () { if (this.student.id === undefined) { axios.post("/StudentManager/addStudentServlet", this.student).then((resp) =>{ if (resp.data.flag){ this.getData(); }else { alert("Add failed!"); } }); }else { axios.post("/StudentManager/updateStudentServlet", this.student).then((resp)=>{ if (resp.data.flag){ this.getData(); }else { alert("Modification failed!"); } }); } }, deleteStudent:function (id) { axios.post("/StudentManager/deleteStudentServlet?id="+id).then((resp)=>{ if (resp.data.flag){ this.getData(); }else { alert("Delete failed!"); } }); }, findById:function (id) { axios.post("/StudentManager/findByIdStudentServlet?id=" + id).then((resp)=>{ this.student = resp.data; }); } }, mounted:function () { this.getData(); } }); </script> Display paginated student information // Servlet String currentPage = request.getParameter("currentPage"); String pageSize = request.getParameter("pageSize"); PageBean<Student> pageBean = showAllStudentService.showAllStudent(Integer.parseInt(currentPage), Integer.parseInt(pageSize)); ObjectMapper objectMapper = new ObjectMapper(); String json = objectMapper.writeValueAsString(pageBean); response.getWriter().write(json); // Service @Test @Override public PageBean<Student> showAllStudent(int currentPage, int pageSize) { PageHelper.startPage(currentPage, pageSize); SqlSession sqlSession = SqlSessionUtils.getSqlSession(false); StudentMapper mapper = sqlSession.getMapper(StudentMapper.class); List<Student> students = mapper.showStudent(); PageInfo<Student> pageInfo = new PageInfo<>(students); long total = pageInfo.getTotal(); int pages = pageInfo.getPages(); PageBean<Student> pageBean = new PageBean<>(total, students, pages); sqlSession.close(); return pageBean; } //Dao /** * Home page shows all students* @return student list*/ @Select("SELECT * FROM student") List<Student> showStudent(); The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Use Shell scripts to batch start and stop Docker services
>>: Tutorial on upgrading, installing and configuring supervisor on centos6.5
Table of contents 1. Usage of keep-alive Example ...
This article shares the specific code for JavaScr...
<br />Table is an awkward tag in XHTML, so y...
Table of contents 1. How to represent the current...
cursor A cursor is a method used to view or proce...
Overview UNION The connection data set keyword ca...
Through the study and application of Node, we kno...
Many organizations have the need to back up file ...
Rich text editors are often used when doing backg...
Table of contents 1. Background of the problem: 2...
Table of contents Problem Description Historical ...
1. Dynamic query rules The dynamic query rules ar...
There are two situations 1. Start time and end ti...
introduction In recent years, the call for TypeSc...
To debug js code, you need to write debugger in t...