在struts中html:select,怎样从数据库中取出数据,加到了html:option中,如显示的是"姓名",但值是"姓名"的ID值,请给出完整源代码,解决后立即给分!谢谢!急!急!急!
解决方案 »
- location.href如何传复选框的值
- socket通讯如何判断读流成功?
- prepareStatement 中的sql语句 为什么不能用like %?% 模糊查询呢?
- jsp的问题 把cookie中的呢称如何放入<input type=text size=10 name=nick>这个html元素中
- 很棘手高手来发表一下!!!!!!。。。。。。
- 网站并发过大,求高手解决连接池配置问题!
- 请问有人能够提供一个在spring架构上面实现的调用jdbc的应用的简单例子吗?谢谢!
- tomcat7下发布项目,连接access数据库报错
- Insert 数据出错?
- 新人求大神解答,关于学习springBoot的学习路径
- 关于页面刷新问题?
- 登录验证的问题 过滤器
<html:option value=""></html:option>
<html:optionsCollection name="limitGridForm" property="statusList" value="wfStatusCode" label="wfStatusName" />
</html:select> ------------
html:optionsCollection name="limitGridForm"
在这里他自己会循环的
这个就是一个集合了
会自动循环的
你在action里面处理之后保存为这个属性
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:option value=""></html:option>
<html:options collection="accountList" labelProperty="khmc" property="khbh"></html:options>
</html:select>collection 为集合
labelProperty 为显示的值
property 为value的值
比如你有个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>
log.debug("finding Bbsuser instance by example");
try {
List results = getSession()
.createCriteria("bean.Bbsuser")
.add(Example.create(instance))
.list();
log.debug("find by example successful, result size: " + results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
} 调用这个方法
dao.getSession().close();
request.setAttribute("Bbsuser ", ss);
<html:select name="随便起个" >
<logic:iterate id="list" name="Bbsuser ">
<html:option value="${list.id}">${list.name}</html:option>
</logic:iterate>
</html:select>
不就是取出数据来么?