问题
Below is the html tag multibox which i want to migrate it to struts 2
<html:multibox name="unitForm" property="eservices">
<bean:write name="service"/>
</html:multibox>
as it is checkbox so thought of using simple checkbox which is in the iterator so i used below code
<s:checkbox theme="simple" name="unitForm.eservices"></s:checkbox>
in action
String[] toArray = new String[selectedadminVOs.size()];
unitForm.setEservices(selectedadminVOs.toArray(toArray));
stuck here,without or minimal changes in action code how can i migrate it to struts2
回答1:
The equivalent in Strust2 is
<s:iterator var="row" value="%{unitForm.eservices}">
<input type="checkbox" name="unitForm.checked"
value="${row.service}" ${unitForm.checked.contains(row.service)?'checked="checked"':''}/>
</s:iterator>
or you can use s:property
tag
<s:iterator var="row" value="%{unitForm.eservices}">
<input type="checkbox" name="unitForm.checked"
value="${row.service}" <s:property value="%{unitForm.checked.contains(#row.service)?'checked="checked"':''}"/>/>
</s:iterator>
来源:https://stackoverflow.com/questions/26629210/htmlmultibox-equivalent-in-struts-2