jsp页面显示数据库的数据信息表,jsp信息表分享


在日常jsp开发中;最基本的一个操作之一是把之前添加到数据库中的信息在jsp页面中显示出来,也就是增删改查中的查找的一部分;

下面是以上部分的开发步骤及分析。

1.在jsp页面:

 <thead> <tr> <th>用户名称</th> <th>用户性别</th> <th>用户年龄</th> </tr> </thead> <tbody> <% AccountDAO accountdao=new AccountDAO(); List list=accountdao.select();//从数据库中查询所有的用户,得到的是一个集合(数组)  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")?"男":"女")+"");  out.write(""+account.getAge()+"");  out.write(""); } %> </tbody> 

2.在html页面:

 <thead> <tr> <th>用户名称</th> <th>用户性别</th> <th>用户年龄</th> </tr> </thead> <tbody> <tr> <td>王五</td> <td>男</td> <td>20</td> </tr> <tr> <td>里斯</td> <td>男</td> <td>22</td> </tr> </tbody>

jsp页面和html页面:

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/jspttutorial/111886.html

(0)
上一篇 2020年5月8日
下一篇 2020年5月8日

精彩推荐