<html:select property="marriage"> 
<%if(emp.getMarriage().equals("是")) 

%> 
<html:option value="是"></html:option> 
<html:option value="否"></html:option> 
<% 

if(emp.getMarriage().equals("否")) 

%> 
<html:option value="否"></html:option> 
<html:option value="是"></html:option> 
<%} %> 
</html:select> ========= 
我在做修改人员资料时候,在下拉式菜单处理中是这么做的,但感觉很笨。尤其要是遇到下拉菜单中有多个属性的时候,这么写就更笨了,要是预先还不知道有多少,如(很多部门都是从数据库中遍历到下拉菜单中的情况),那就更难办了

解决方案 »

  1.   

    <html:select property="languageId" name="ProductForm">
    <bean:define id="glist" name="languagelist"></bean:define>
    <html:options collection="glist" property="languageId" labelProperty="languageName" />
    </html:select>
      

  2.   

    <html:select property="selectName2" size="10">
    <html:options collection="selectData" property="value" labelProperty="label"/>
    </html:select>
    在进入这个画面的action中set一下你上面那个变量就行了,如:form.setSelectName2(emp.getMarriage());
      

  3.   

    selectData是你从数据库中取出来的集合。
      

  4.   

    看你用的是struts
    用el语句
       <option value="0" selected="${item.value}==**:true?false"></option>
     就是这么个意思,自己去查资料吧            
      

  5.   

    楼主这是干什么呢?
    下拉列表,你就直接给赋值就是了,,那样你是给选择吗?你那样并没有选择啊。例如你从action里面传过来需要修改的数据为editObject,你在jsp页面这样就可以了。
    <bean:define id="edit" name="editObject"/>
    <html:select property="marriage" value="${edit.marriage}">
       <html:option value="是">是</html:option>
      <html:option value="否">否</html:option>
    </html:select> //文本框
    <html:text property="name" value="${edit.name}"/>就可以了,当然前提是你必须有这个表的pojo类。。不然不能使用上面的方法。
      

  6.   

    看看我的写法,不知道会不会简单一些:
    ----------------------
    <html:select property="doc">
          <html:option value="">--------不用模版--------</html:option>
          <logic:iterate id="Doctem" name="temList" type="ActionForms.DocumentList_ActionForm" scope="request">
            <logic:equal name="Doctem" property="fileType" value=".doc">
              <html:option value="${Doctem.recordID}">${Doctem.descript}</html:option>
            </logic:equal>
          </logic:iterate>
        </html:select>
    ----------------------<logic:iterate 用来遍历temList传过来的信息列表
    <logic:equal 用来判断文档格式