Code analysis of paging function implemented by JavaBean servlet JSP
The front-end implementation uses liger UI to realize paging. It feels that the framework is really simple and idle. It simulates liger's paging interface and realizes it again (as long as it is function and style, ignore it)
This is implemented with the basic three-tier architecture + servlet + JSP. The idea is very simple. Write all paging related information into a pagebean class, and the service returns this bean class. Each paging query will find information from this bean. However, the details are cumbersome, such as boundary processing (both front-end and background boundaries need to be processed), the current page should be displayed after the drop-down box jumps, and so on
This is the paging style implemented by ligerui (the implementation process was written in my last blog: http://www.jb51.net/article/92850.htm )
Simulation implementation process:
directory structure
@H_ 502_ 23@
Database (MySQL)
In the model layer, there is a model (blog) corresponding to the database and a pagebean (blogpage)
Dao layer
JDBC util encapsulates the connection and release operations of JDBC
Service layer
Servlet class
In this way, all paging information is encapsulated in the page bean
The JSP implementation only needs to take out the information in the page bean
Here is my JSP implementation (simulating ligerui)
This is as like as two peas in the final form, with a rough style and the same function as ligerUI's default paging.
Change the code in the JSP to a tag (JSTL, the corresponding jar package needs to be introduced) and put the footer in the JSP in the servlet
Add in Servlet
JSP page
In practice, JSP pages can be written according to requirements, but the background code is basically universal
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.