高手们哪位知道,java servlet 输出一个list 到jsp页面 循环在table中?
public List find_meiricq_smc(String sql) {Connection con = DbConnection_tcc.getConnection();
sql = "SELECT xuehao, name,kahao FROM ICCO.dbo.V_xsdaoru ";
List<String> lis = new ArrayList<String>();
int id = 0;
try {
PreparedStatement stmt = con.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
lis.add(rs.getString(1));
lis.add(rs.getString(2));
lis.add(rs.getString(3));
lis.add("");
}
} catch (Exception e) {
Log.log(this, "queryUser:" + e);
e.printStackTrace();
} finally {
ConnTools.close(con);
}
return lis;
}
}
java Struts + Spring +servlet 我从执行这个sql 返回一个lis 而我在Action层 获取list 输出list到jsp页面
List list = service.ussyzbt(sql);
try {
request.setAttribute("list", list);
request.getRequestDispatcher("table-jsp").forward(request,response);
} catch (Exception e) {
e.printStackTrace();
}}
而我在jsp页面 这样获取
ArrayList list = (ArrayList)request.getAttribute("list");
我要怎么遍历这个list 循环在一个table中