struts的复选框html:multibox的问题

vito_fh 2007-04-24 12:42:26
为什么在页面上html:multibox的取值数组的长度为0;
JSP页面:
Vector vecPart=(Vector)session.getAttribute("partList");
TopicDisp partList=null;
if(vecPart!=null)
{
for(int i=0;i<vecPart.size();i++)
{
partList=(TopicDisp)vecPart.get(i);
%>
<tr bgcolor="#CCFFFF">
<td>
<html:multibox property="selectBox"><%=partList.getId()%></html:multibox><%=partList.getId()%>
</td>
<td><%=partList.getId()%></td>
<td><%=partList.getTitle()%></td>
<td><%=partList.getContent()%></td>
</tr>
<%
}
}

FORM页面:
private String[] selectBox=new String[0];

public String[] getSelectBox()
{
return selectBox;
}

public void setSelectBox(String[] selectBox)
{
this.selectBox = selectBox;
}

public void reset(ActionMapping mapping,HttpServletRequest request)
{
this.selectBox=new String[0];
}

ACTION部分为:
SaveRecrodForm sForm=new SaveRecrodForm();
String[] sId=sForm.getSelectBox();

System.out.println("sId.length="+sId.length);
for(int i=0;i<sId.length;i++)
System.out.println(sId[i]);
...全文
309 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
vito_fh 2007-04-25
  • 打赏
  • 举报
回复
再次补充一下,这个JSP页面:
Vector vecPart=(Vector)session.getAttribute("partList");
TopicDisp partList=null;
if(vecPart!=null)
{
for(int i=0;i<vecPart.size();i++)
{
partList=(TopicDisp)vecPart.get(i);
%>
<tr bgcolor="#CCFFFF">
<td>
<html:multibox property="selectBox"><%=partList.getId()%></html:multibox>
</td>
<td><%=partList.getId()%></td>
<td><%=partList.getTitle()%></td>
<td><%=partList.getContent()%></td>
</tr>
<%
}
}

因为这个页面不是最开始的jsp页面,是有通过筛选跳转显示的部分记录;页面的路径上也显示是以 .do结尾的路径;会不会不支持这样的选择;
我创建新的页面里,写个新的:如下
<html:form action="/selectBoxTest.do">
<%for(int i=0;i<5;i++){%>
Multilbox<%=i%>:<html:multibox property="strArray">Value<%=i%></html:multibox><BR>
<%}%>
<html:submit/><html:cancel/>
</html:form>
就能很好的读取我所要的所选的复选框!
请哪位指导一下;

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧