<c:forEach>取list里的值
while(res.next()){user.setId(res.getInt("id"));intid=user.getId();list.add(id);user.s...
while(res.next()){
user.setId(res.getInt("id"));
int id = user.getId();
list.add(id);
user.setName(res.getString("name"));
String name = user.getName();
list.add(name);
user.setPassword(res.getString("password"));
String password = user.getPassword();
list.add(password);
}
request.setAttribute("list",list);
jsp中该怎么写才可以去除list集合中的每个值?
现在改成这样 TestBean tb = new TestBean();
ResultSet res = tb.findAll();
List list = new ArrayList();
User user = new User();
try{
while(res.next()){
user.setId(res.getInt("id"));
int id = user.getId();
user.setName(res.getString("name"));
String name = user.getName();
user.setPassword(res.getString("password"));
String password = user.getPassword();
list.add(user);
}
} catch (SQLException sq) { }
request.setAttribute("list",list);
这样似乎集合里也只有那么一个,前面的都被覆盖了,应该怎么修改呢? 展开
user.setId(res.getInt("id"));
int id = user.getId();
list.add(id);
user.setName(res.getString("name"));
String name = user.getName();
list.add(name);
user.setPassword(res.getString("password"));
String password = user.getPassword();
list.add(password);
}
request.setAttribute("list",list);
jsp中该怎么写才可以去除list集合中的每个值?
现在改成这样 TestBean tb = new TestBean();
ResultSet res = tb.findAll();
List list = new ArrayList();
User user = new User();
try{
while(res.next()){
user.setId(res.getInt("id"));
int id = user.getId();
user.setName(res.getString("name"));
String name = user.getName();
user.setPassword(res.getString("password"));
String password = user.getPassword();
list.add(user);
}
} catch (SQLException sq) { }
request.setAttribute("list",list);
这样似乎集合里也只有那么一个,前面的都被覆盖了,应该怎么修改呢? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询