The jsp page displays the database data information table and jsp information table.
In daily jsp development, one of the most basic operations is to display the information previously added to the database on the jsp page, which is part of the Search In addition, deletion, modification, and query;
The following are the development steps and Analysis of the above section.
1. On the jsp page:
<Thead> <tr> <th> User Name </th> <th> User gender </th> <th> User age </th> </tr> </thead> <tbody> <% AccountDAO accountdao = new AccountDAO (); list list = accountdao. select (); // query all users from the database. A set (array) for (int I = 0; I <list. size (); I ++) {Account account = list. get (I); out. write (""); out. write ("" + account. getAname () + ""); out. write ("" + (account. getSex (). equals ("m ")? "Male": "female") + ""); out. write ("" + account. getAge () + ""); out. write ("") ;}%> </tbody>
2. On the html page:
<Thead> <tr> <th> User Name </th> <th> User gender </th> <th> User age </th> </tr> </thead> <tbody> <tr> <td> Wang Wu </td> <td> male </td> <td> 20 </td> </tr> <td> RIS </td> <td> male </td> <td> 22 </td> </tr> </tbody>
Jsp page and html page:
Data in the database:
The two show the same effect, but one is a dynamic webpage and the other is a static webpage.
Part II code:
TeacherDao teacherDao = new TeacherDao (); List <Teacher> teachers = teacherDao. findAllTeacher (); for (int I = 0; I <teachers. size (); I ++) {Teacher teacher = teachers. get (I ); %> <tr> <td> <input name = "" type = "checkbox" value = ""/> </td> <% = teacher. getTno () %> </td> <% = teacher. getTname () %> </td> <% = teacher. getTsex () %> </td> <% = teacher. getProf () %> </td> <% = teacher. getDepart () %> </td> <% = teacher. getTbirthday () %> </td> <a href = "#" class = "tablelink"> View </a> <a href = "#" class = "tablelink"> delete </a> </td> </tr> <%} %>
Conclusion: Learn with your heart and pay attention to the summary!
The above is all the content of this article. I hope this article will help you in your study or work. I also hope to provide more support to the customer's home!