<html:select property="if_end">
<option value="0">否</option>
<option value="1">是</option>
</html:select>
将option中value的值给if_end
动态用法一:
<html:select property="personnelId">
<html:option value="">请选择</html:option>
<html:options collection="personList" property="personId" labelProperty="personName"/>
</html:select>
html:options自动帮你迭代personList中的内容,前提是personList是Collection类型的,而且封装的是一个包含personId,personName属性的对象
property显示的是value,labelProperty显示的是页面看到的内容
动态用法二:
有时候用标签的限制太多就用下面这个:
<SELECT name="deid">
<logic:iterate id="depart" name="departarray1" >
<option value="<bean:write name="depart" property="deId"/>">
<bean:write name="depart" property="deName"/>
</option>
</logic:iterate>
</SELECT>
上文转载自:http://hi.baidu.com/kekemao1/blog/item/759087fdb5cb0144d7887d4c.html
另:在struts程序编写中:
若后台封装是labelValueBean形式前台可写成:
<html:select property="deptcode" style="width:95px;">
<html:options collection="deptlist" property="value" labelProperty="label"/>
</html:select>
或:
<logic:notEmpty
name="messageForm" property="deptlist">
<html:select property="deptcode" style="width:50%;">
<html:optionsCollection property="deptlist" label="label"
value="value" />
</html:select>
</logic:notEmpty>
后台代码可写成:
List strdeptlist = new ArrayList();
List deptList = new ArrayList();
// 得到部门信息list
strdeptlist = service.findDepart();
WebSysDepartment bean = null;
String tempKey = "";
String tempValue = "";
for (int i = 0; i < strdeptlist.size(); i++) {
bean = (WebSysDepartment)strdeptlist.get(i);
// 部门名(名)
tempKey = bean.getDeptName();
// 部门code(值)
tempValue = bean.getDeptCode();
(tempKey = ((Map) tempList.get(i)).get("DEPT_NAME").toString();
tempValue = ((Map) tempList.get(i)).get("DEPT_CODE").toString();
)
deptList.add(new LabelValueBean(tempKey, tempValue));
}
// 将信息放到request中
request.setAttribute("deptlist", deptList);