页面中的form如下:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><html:form method="post" action="/roles/add.do">
<table border="0" cellspacing='0' cellpadding='0' width="80%" height="200">
<tr>
<td align="left">
<div style="display:block;overflow-y:scroll;overflow-x:auto;height:280px;">
<c:forEach items="<%=list %>" var="unit">
<html:checkbox property="unitsid" value="${unit.id}">
${unit.name}
</html:checkbox>
<br/>
</c:forEach>
</div>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<html:submit value="提交"/> <html:reset value="取消"/>
</td>
<td>
</tr>
</table>
</html:form>在容器中有对应的Form设置了String unitsid的属性和getter、setter方法,
问题在于form读到的unitsid只有所有checkbox中被选中的第一个的值,其他的并未被传入求struts高手帮忙,怎么把checkbox的数据一起提交给form,然后怎么解析,谢谢!
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><html:form method="post" action="/roles/add.do">
<table border="0" cellspacing='0' cellpadding='0' width="80%" height="200">
<tr>
<td align="left">
<div style="display:block;overflow-y:scroll;overflow-x:auto;height:280px;">
<c:forEach items="<%=list %>" var="unit">
<html:checkbox property="unitsid" value="${unit.id}">
${unit.name}
</html:checkbox>
<br/>
</c:forEach>
</div>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<html:submit value="提交"/> <html:reset value="取消"/>
</td>
<td>
</tr>
</table>
</html:form>在容器中有对应的Form设置了String unitsid的属性和getter、setter方法,
问题在于form读到的unitsid只有所有checkbox中被选中的第一个的值,其他的并未被传入求struts高手帮忙,怎么把checkbox的数据一起提交给form,然后怎么解析,谢谢!
<action attribute="unitsForm" name="unitsForm"
path="/units/act" type="org.springframework.web.struts.DelegatingActionProxy"
scope="request" validate="false">
<forward name="done" path="/test.jsp" />
</action>unitsForm中:
private String unitsid;
然后有getter和setter方法action中就是打印unitsid的值,怎么看也只有一个。。