j2ee 高手帮我分析下

来源:百度知道 编辑:UC知道 时间:2024/05/30 10:27:12
public class Findaction extends Action{
Connection conn=null;
public static boolean isNumeric(String str){
for (int i = str.length();--i>=0;){
if (!Character.isDigit(str.charAt(i))){
return false;
}
}
return true;
}

public ActionForward execute(ActionMapping arg0, ActionForm arg1, HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
conn=Factoryconn.getcn();
String sql1="select count(cid) from dbo.lovewall";
PreparedStatement ps1=conn.prepareStatement(sql1);
ResultSet rs1=ps1.executeQuery();

List list1 =new ArrayList();
while(rs1.next()){
Usedto dto1=new Usedto(rs1.getInt(1));
list1.add(dto1);
arg2.setAttribute("list1", dto1);
}rs1.close();
ps1.close();

List list =new ArrayList();
String fl=arg2.getParameter("tj");
String id=arg2.

List L = new ArrayList();
while (rs.next())
{
String date = rs.getString("cdate");
date = date.substring(0, 19);

Usedto dto = new Usedto(rs.getInt("cid"), date, rs
.getString("cauthor"), rs.getString("ccontent"), rs
.getString("cfcolor"), rs.getString("cbcolor"));

L.add(dto);
}
arg2.setAttribute("lists", L);

把list和setAttribute放到while循环外面。