CSDN博客

img Arqui

关于iterate的感受

发表于2004/10/11 17:17:00  1136人阅读

今天所做的iterate标签真的很有意思,以前不是很明白他的真正含义。
原来他只能对vector一类的2维进行操作,先前用数组当然就不行拉,总是提示我的collection不能用iterate来表示。
form还要这样写:
/*
 * Created on 2004-10-11
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package eg.jl.message.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionForm;

import eg.jl.message.beans.Account;

/**
 * @author Administrator
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class CheckActionForm extends ActionForm{
 
 private Account[] account; 

    public Account[] getAccount()
    {
   return account;
    }
  
    public void setAccount(Account[] account)
    {
   this.account = account;
    }
  

}
actionk的bean中这样写:
public static Account[] getUser(HttpServletRequest request,java.sql.Connection connection) throws java.sql.SQLException
   {
  String selected = request.getParameter("selected");
  String sql = "SELECT * FROM MA_USER WHERE USERID='"+selected+"'";
  java.sql.Statement statement = connection.createStatement();
  ResultSet resultSet = statement.executeQuery(sql);
  ArrayList arrayList = new ArrayList();
 
  resultSet.next();
  String userID = resultSet.getString("USERID");
  String password = resultSet.getString("PASSWORD");
  String userName = resultSet.getString("USERNAME");
  String userType = resultSet.getString("USERTYPE");
  String address = resultSet.getString("ADDRESS");
  Account account = new Account(selected,userID,password,userName,address,userType); 
  arrayList.add(account);
  return (Account[])arrayList.toArray(new Account[arrayList.size()]);
   }
哎呀 真是浪费资源,一条记录也用iterate的话还要装成vector的样子,真是罪过罪过。

阅读全文
0 0

相关文章推荐

img
取 消
img