<jsp:useBean id="request_b_list" class="java.util.ArrayList" scope="request" />
<logic:iterate id="bList" name="request_b_list">
<tr>
<td><%=((BrEx)bList).getCreateUser()%></td>
<td><%=((BrEx)bList).getCreateDate()%></td>
</tr>
</logic:iterate>
<logic:iterate id="bList" name="request_b_list">
<tr>
<td><%=((BrEx)bList).getCreateUser()%></td>
<td><%=((BrEx)bList).getCreateDate()%></td>
</tr>
</logic:iterate>
如果出现你所说的情况,那么你的hashmap可能是这样舍得hashmap.put("xxx",cartbean);
要得到cartbean下的值可以使用<bean:define>
<bean:define id="cartbean" name=cartid property=value>
<bean:write name="cartbean " property="property"/>//property是指你在cartbean中的属性
我们是放在Vector中,(cartMap为Vector的键)
<logic:iterate id="cartid" name="cartMap">
<bean:write name="cartid" property="membername"/>
</logic:iterate>
HashMap试一下,从HashMap中根据键取应该可以吧
<logic:iterate id="cartid" name="cartHashMap">
<bean:write name="cartid" property="key"/>
<bean:write name="cartid" property="value"/>
</logic:iterate>
你把它们一个一个的放到一个ArrayList对象里面,<logic>这个ArrayList对象看一下。
<logic:iterate id="findalltrainhead" property="findalltrainheadresult" > <tr>
<td nowrap bgcolor="#CCCCCC"><input type="checkbox" name="checkbox22" value="checkbox"></td>
<td height="31" nowrap bgcolor="#CCCCCC">
<bean:write name="findalltrainhead" property="trainHeaderCode"/>
</td>
<td bgcolor="#CCCCCC">
<bean:write name="findalltrainhead" property="deptName"/>
</td>
<td bgcolor="#CCCCCC">
<bean:write name="findalltrainhead" property="headerTypeName"/>
</td>
<td height="31" bgcolor="#CCCCCC">
<bean:write name="findalltrainhead" property="telNum"/>
</td>
</tr>
</logic:iterate>我的函数是这样写的
public ArrayList finAllTrainHead()
throws Exception{
getConnection(); //连接数据库
PreparedStatement ps = null;
ResultSet rs = null;
String sql= null;
ArrayList arrayList = new ArrayList();//返回结果
try{
sql= " select distinct(Btbl_TrainHeaderInfo.TrainHeaderID),Btbl_TrainHeaderInfo.*, "
+" Btbl_TrainHeaderType.HeaderTypeName,Btbl_OrganizationInfo.DeptName "
+" from Btbl_TrainHeaderInfo,Btbl_TrainHeaderType,Btbl_OrganizationInfo "
+" where Btbl_TrainHeaderInfo.DepartmentCode = Btbl_OrganizationInfo.DepartmentCode "
+" and Btbl_TrainHeaderInfo.TrainHeaderTypeId = Btbl_TrainHeaderType .HeaderTypeID ";
ps = conn.prepareStatement(sql);
rs = ps.executeQuery(); while(rs.next()){
TrainHeadForm trainHeadForm = new TrainHeadForm();
trainHeadForm.setTrainHeaderCode(rs.getString("TrainHeaderCode"));
trainHeadForm.setDeptName(rs.getString("DeptName"));
trainHeadForm.setHeaderTypeName(rs.getString("HeaderTypeName"));
trainHeadForm.setTelNum(rs.getString("TelNum"));
arrayList.add(trainHeadForm);
}
}catch(Exception ex){
System.out.println("error call finAllTrainHead():" + ex.getMessage());
}finally{
if(conn != null){
conn.close();
}
if(ps != null){
ps.close();
}
if(rs != null){
rs.close();
}
}
//返回结果
return arrayList;
}
我的execute方法中是这样写的
if(trainHeadForm.getOperate().equals("findAllTrainHead"))
{
ArrayList arrayList = new ArrayList() ;
try{
arrayList = finAllTrainHead();
if(arrayList ==null)
{
ActionErrors errors = new ActionErrors();
ActionError error = new ActionError("trainhead.findalltrainhead.noresult");
errors.add(ActionErrors.GLOBAL_ERROR,error);
saveErrors(httpServletRequest,errors);
//如果车头行增加失败,转向trainHeadAdd.jsp页面
return (actionMapping.findForward("findall_trainhead_noresult")); }
HttpSession session = httpServletRequest.getSession();
session.setAttribute("findalltrainheadresult", arrayList);
return (actionMapping.findForward("findall_trainhead_result")); }catch(Exception ex)
{
throw ex;
}
}
return (actionMapping.findForward("addTrainHead"));
}
}注意:
<logic:iterate id="findalltrainhead" property="findalltrainheadresult" >
这个id是自己随便定义的便于显示列表中的每行值,property是Action中ArrayList的返回值,另外在actionForm中要写明get set 方法呵呵楼主试验一下可以的