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