日期:2014-05-18  浏览次数:20832 次

在struts中html:select,怎样从数据库中取出数据,加到了html:option中
在struts中html:select,怎样从数据库中取出数据,加到了html:option中,如显示的是 "姓名 ",但值是 "姓名 "的ID值,请给出完整源代码,解决后立即给分!谢谢!急!急!急!

------解决方案--------------------
<html:select name= "limitGridForm " property= "searchCriteria.dataStatus ">
<html:option value= " "> </html:option>
<html:optionsCollection name= "limitGridForm " property= "statusList " value= "wfStatusCode " label= "wfStatusName " />
</html:select>

------------
html:optionsCollection name= "limitGridForm "
在这里他自己会循环的
------解决方案--------------------
action中:request.setAttribute( "list ",personlist);
jsp页面中:
<html:select name= "fdf " >
<logic:iterate id= "list " name= "list ">
<html:option value= "${list.id} "> ${list.name} </html:option>
</logic:iterate>
</html:select>
------解决方案--------------------
<html:select property= "khbh ">
<html:option value= " "> </html:option>
<html:options collection= "accountList " labelProperty= "khmc " property= "khbh "> </html:options>
</html:select>

collection 为集合
labelProperty 为显示的值
property 为value的值
------解决方案--------------------
action 里这样写
比如你有个bean类,里面就两个字段,name和id,类名假设为bean
用hibernate的 方法get(new bean())得到一个list <bean>
用个引用list接收,然后request.setA...( "list ",list);
jsp页面中:
<html:select name= "随便起个 " >
<logic:iterate id= "list " name= "list ">
<html:option value= "${list.id} "> ${list.name} </html:option>
</logic:iterate>
</html:select>