这是从数据库取数据的方法,我想知道jsp页面如何接受到这个结果集,并且循环遍历输出,谢谢,请详细一点
[code="java"] public List> custom(String staff){
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
List> list = null;
try{
con = JavaUtil.getInstence().getConnection();
String sql = "select name,linkman,contact,details,address from customer where staff = ?";
ps = con.prepareStatement(sql);
ps.setString(1, staff);
rs = ps.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
int count = rsmd.getColumnCount();
String[] colNames = new String[count];
for(int i=0;i
colNames[i] = rsmd.getColumnLabel(i+1);
}
list = new ArrayList>();
while(rs.next()){
Map map = new HashMap();
for (int i = 1; i < colNames.length; i++) {
map.put(colNames[i], rs.getObject(colNames[i]));
}
list.add(map);
}
}catch(Exception e){
e.printStackTrace();
}finally{
JavaUtil.getInstence().free(rs, ps, con);
}
return list;
}[/code]