Struts标签<html:select>动态赋值并赋默认值
action中:
DocForm docinfo = (DocForm) form;
List fristdeptlist = docDao.getFristDept();
List deptidlist=new ArrayList();
for(int i=0;i<fristdeptlist.size();i++){
TblDept tbldept=(TblDept)fristdeptlist.get(i);
deptidlist.add(tbldept.getDtid());
}
List deptnamelist=new ArrayList();
for(int i=0;i<fristdeptlist.size();i++){
TblDept tbldept=(TblDept)fristdeptlist.get(i);
deptnamelist.add(tbldept.getDeptname());
}
request.setAttribute("deptidlist", deptidlist);
request.setAttribute("deptnamelist", deptnamelist);
jsp页面:
<html:select name="docForm" property="firstdtid">
<html:options name="deptidlist" labelName="deptnamelist" />
</html:select>