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

解决方案 »

  1.   

    <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"
    在这里他自己会循环的
      

  2.   

    name="limitGridForm"
    这个就是一个集合了
    会自动循环的
    你在action里面处理之后保存为这个属性
      

  3.   

    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>
      

  4.   

    <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的值
      

  5.   

    能否把Action写得具体点,我是初学者,
      

  6.   

    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>
      

  7.   

    public List findByExample(Bbsuser instance) {
            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;
            }
        }    调用这个方法
      

  8.   

    List ss=dao.findByExample(new Bbsuser ());
     dao.getSession().close();
            request.setAttribute("Bbsuser ", ss);
      

  9.   

    jsp页面中:
    <html:select name="随便起个" >  
        <logic:iterate id="list" name="Bbsuser ">
            <html:option value="${list.id}">${list.name}</html:option>
        </logic:iterate>       
    </html:select>
      

  10.   

    不好意思,我是想从数据库中取出数,在用html:select显示出来
      

  11.   

    我是想从数据库中取出数,在用html:select显示出来????什么叫取出数啊?List ss=dao.findByExample(new Bbsuser ());
    不就是取出数据来么?
      

  12.   

    hibernate就是取数据库里查询数据