jsp报表成列显示数据 ,求
jsp表格成列显示数据 ,急求
所有数据在数据库都有,想在表格显示效果如图:
名字 电话号码 性别 E-mail 分类
张三 15479463543 男 6767676 同事
。 。。 。。。。。。。。。。。。。。。。。。
如此排列 才学 不知道咋写 求各位前辈 高手帮忙
------解决方案--------------------
后台java写个userVo类,里面有名字 电话号码 性别 E-mail 分类 等等字段
然后通过sql从数据库中把上列字段取出来放到List<userVo> list中。。。
把list放到request.setAttribute("resList", list)以传到前台jsp,
前台jsp根据key resList通过iterator标签输出至表格。。。
------解决方案--------------------
所有数据在数据库都有,想在表格显示效果如图:
名字 电话号码 性别 E-mail 分类
张三 15479463543 男 6767676 同事
。 。。 。。。。。。。。。。。。。。。。。。
如此排列 才学 不知道咋写 求各位前辈 高手帮忙
------解决方案--------------------
后台java写个userVo类,里面有名字 电话号码 性别 E-mail 分类 等等字段
然后通过sql从数据库中把上列字段取出来放到List<userVo> list中。。。
把list放到request.setAttribute("resList", list)以传到前台jsp,
前台jsp根据key resList通过iterator标签输出至表格。。。
------解决方案--------------------
- Java code
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>产品列表</title> </head> <body> <table border="1" width="500" align="center"> <caption><h1>产品列表</h1></caption> <tr> <th>姓名</th> <th>电话号码</th> <th>性别</th> <th>email</th> <th>分类</th> </tr> <% Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","123"); PreparedStatement ps=con.prepareStatement("select * from product"); ResultSet rs=ps.executeQuery(); while(rs.next()){ %> <tr> <!-- <td><%out.println(rs.getInt("id")); %></td> --> <td><%=rs.getInt("id") %></td> <td><%out.println(rs.getString("name")); %></td> <td><%out.println(rs.getString("type"));%></td> <td><%out.println(rs.getFloat("price"));%></td> <td><%out.println(rs.getString("company"));%></td> </tr> </table> </body> </html>