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 Preface zx library $`command` c...
When coding, you will find that many things have ...
This article uses examples to describe common bas...
This article introduces the sample code of CSS pi...
When the front-end and back-end interact, sometim...
MySQL regular sorting, custom sorting, and sortin...
How to configure custom path aliases in Vue In ou...
When using Docker containers, it is more convenie...
The shutdown.bat file has a sentence if not "...
This article example shares the specific code of ...
A problem that front-end developers often encount...
Variables defined in SASS, the value set later wi...
Table of contents 1. beforeCreate and created fun...
This article shares the Vant Uploader component f...
1. HTML code Copy code The code is as follows: Ex...