用value属性不行吗?我没试过

解决方案 »

  1.   

    用html:select里的indexed属性试试,好像indexed的值表示要被选中的顺序号,如indexed="1"的时候就是list的第一个数据被选中。
      

  2.   

    <select name='dw'>
                <option value="id1">value1</option>
                <option value="id2" selected>value2</option>
                <option value="id3">value3</option>
             </select>
      

  3.   

    在ActionForm中set值,要用Struts的MVC思想,从Action到JSP
      

  4.   

    action里form.set("departmentid");就可以拉
      

  5.   

    struts的表单有优先选择特性
    例如:<html:form action="..">如果你的传到UserForm property userSecurity 属性 = "AA"
    而此时集合groupList里有个对象obj的groupId属性也 = "AA" 则会自动选择到该项上
    显示的内容为 obj对象的description属性
    .. 
    <html:select property="userSecurity">
      <logic:present name="groupList">
        <html:options collection="groupList" 
                      property="groupId" 
                      labelProperty="description"/>
      </logic:present>
    </html:select></html:form>
      

  6.   

    Gwyongcheng(guowei)  的解决方法很简单而且有效
    同时同意 枫的看法
      

  7.   

    这个只要在reset方法中,用setXXX方法设置一下
    下拉框的值就可以了啊
      

  8.   

    如果你不需要重新load数据的话你可以用javaScript来实现你的功能。
    如果你需要重新reload数据,你当然也可以在server端实现。
      

  9.   

    private ArrayList showCountryName(HttpServletRequest req) throws Exception {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        ArrayList result = new ArrayList();
        String sql = null;
        try {
          sql = "SELECT * FROM country  ";
          conn = connectionPool(req);
          ps = conn.prepareStatement(sql);
          rs = ps.executeQuery();
          while (rs.next()) {
            LabelValueBean labelValue = new LabelValueBean(rs.getString(
                "country_name"), rs.getString("id"));
            result.add(labelValue);
          }
        }
        catch (Exception ex) {
          throw new StrutsException("read.error.database");
        }
        finally {
          if (rs != null) {
            rs.close();
          }
          if (ps != null) {
            ps.close();
          }
          if (conn != null) {
            conn.close();
          }    }
        return result;
      }
    这是在execute方法中写的
     if (type.equals("add")) {
          ArrayList country_ary = new ArrayList();
          try {
            country_ary = showCountryName(req);
            if (country_ary.size() > 0) {
              req.setAttribute("country", country_ary);
              return mapping.findForward("province.add.success");
            }
            else {
              req.setAttribute("country", country_ary);
              return mapping.findForward("province.add.fail");
            }
          }
          catch (StrutsException ex) {
            req.setAttribute("country", country_ary);
            errors.add(ActionErrors.GLOBAL_ERROR,
                       new ActionError(ex.getMessage()));
            saveErrors(req, errors);
            return mapping.findForward("province.add.fail");
          }
        }
    标签为:
       <html:select name="provinceForm" property="countryID" style="width:150">
                   <html:option value="">please select</html:option>
                     <html:options collection ="country" property ="value" labelProperty ="label"  />
                 </html:select>
    provinceForm是form的名称,property是select的属性
    传过来的值为coutry,这样就能正确显示
      

  10.   

    actionForm.setDepartmentid("你所取得的id")