我需要在S2中创建多个复选框,如下所示。在Struts2中创建多个复选框
使用此代码,我只得到一个复选框
public class EmployeeListBean {
private String empCode = null;
private String empName = null;
public EmployeeListBean(String empCode,String empName)
{
//constructor
}
//setter and getter methods
}
在动作类
public ArrayList<EmployeeListBean> getListOfEmployees()
{
return listOfEmployees;
}
在执行()
listOfEmployees = new ArrayList<EmployeeListBean>();
listOfEmployees.add(new EmployeeListBean("1", "Smith"));
在JSP中,
<s:iterator value="listOfEmployees">
<s:checkbox name="someselectedname" label="%{empName}" fieldValue="%{empCode}"/><br/>
</s:iterator>
我遵循正常的方式。这里我想在三个复选框中只选择一个复选框。所以我们可以在JS或Jquery中完成。在HTML中,它就像
<label>abc: </label>
<input type="checkbox" name="ballet" />
<input type="checkbox" name="ballet" />
<input type="checkbox" name="ballet" />
<br/>
<label>def: </label>
<input type="checkbox" name="ballet1" />
<input type="checkbox" name="ballet1" />
<input type="checkbox" name="ballet1" />
但我想要以上格式。如何在S2中做到这一点。
那么我建议使用单选按钮而不是复选框。 – Ranjitsinh