Java Simple pagination/summary

Source: Internet
Author: User

Model (Entity)

DAO layer

The implementation of DAO Daoimpl layer

Service Layer

And then the servlet .

Load the service layer into the servlet and you can pass the value, and you'll see the effect immediately.

JSP page came up

Of course you can't forget to add 2 racks of Jstl.jar and Standard.jar in Lib.

And on the JSP page, add <%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>

I didn't write the JDBC tool class.

You can have a look on the internet.

A small detail to be aware of when JDBC closes a connection

When the connection is closed

This section is referenced on the network

Tell me the difference between these two pieces of code:
1, Conn! = NULL This is not sure whether the above connection is initialized and judged, because a lot of time to write code, using lazy loading mode, usually first define a connection conn=null, use the time to initialize its object, This can reduce the waste of memory. This time if you are not sure if Conn is initialized, it is best to add conn! = NULL before closing, otherwise it is possible to close conn with a null pointer error.

2, conn.isclosed ()

This is to determine whether the current connection is closed, this first to ensure that connection: (Preparestatement ,ResultSet ) has already generated an instance.

From a perfect point of view of the program, when closing the connection, it is best to judge two of them:
if (conn!=null&&!conn.isclosed ()) {
Conn.close ();
}

And you finally see the effect.

So happy

Web. Xml

Java Simple pagination/summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.