你把actionForm中的reset方法去掉应该就可以

解决方案 »

  1.   

    回 onray(39度):
    我的form中的reset方法为空,未写。回 xiaopeipei2004(小裴) :
    我也这么想,我尝试过在action中form.setDeptid("2"),不成功
      

  2.   

    把你赋值的和STRUTS-CONFIG中定义这个form的代码贴出来看看
      

  3.   

    action中form.setDeptid("2")是在什么时候执行的呢?如果你想给form中的属性赋初值,你进入页面的时候就要先跳到action中,然后执行form.setDeptid("2"),再return mapping.findForward(“你的页面”)!
      

  4.   

    下面是action中的edit方法:
      /**
       * 编辑数据
       * @param servletRequest HttpServletRequest
       */
      private void edit(HttpServletRequest servletRequest) {
        try {
          classtypeID = servletRequest.getParameter("classtypeID");
          employeesSchema=remote.GetEmployeesByEmployid(classtypeID);
          form.setDuty(employeesSchema.getDuty());
          form.setSex(employeesSchema.getSex());
          form.setState(employeesSchema.getState());
          form.setEdudegree(employeesSchema.getEdudegree());
          form.setDeptid(employeesSchema.getDeptid());// ××××在这里赋值×××××××
          if ("null".equals(employeesSchema.getPhoto()) || null==employeesSchema.getPhoto()) {
            employeesSchema.setPhoto("null");
          }
          servletRequest.setAttribute("action", "edit");
          servletRequest.setAttribute("list", employeesSchema);
        }
        catch (RemoteException ex2) {
        }
      }form是一个jbuilder生成的,reset和vallidate方法还是空的。STRUTS-CONFIG也是生成的,程序运行正常,应该没问题。大家有这种下拉框的代码发给我看看啊。
      

  5.   

    Action中:  
     public ActionForward addItem(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {   ActionErrors errors = new ActionErrors();
      ActionForward forward = new ActionForward();
    ...................
    Rfq_MaterialQueryForm rfq_MaterialQueryForm=new Rfq_MaterialQueryForm();
    rfq_MaterialQueryForm.setPriceunit("0");
    session.setAttribute("rfq_MaterialQueryForm",rfq_MaterialQueryForm); 
    这里的”rfq_MaterialQueryForm“一定要和下面Struts-config中的name属性相同
    ..............
    forward=mapping.findForward("toQtyArea");////////////////////////////////////////////////
    Struts-config中
     <action name="rfq_MaterialQueryForm" path="/rfq_AddItem" type=".....Rfq_AddItemAction" parameter="actionforward">
    .......... 
    <forward name="toqtyArea" path="/RFQMA/RFQ_ITEM_Add_QUA.jsp"></forward>
     </action>
    ///////////////////////////////////////
    jsp中:
                        <html:select property="priceunit">
                          <html:option value="0">1</html:option>
                          <html:option value="1">100</html:option>
                          <html:option value="2">1000</html:option>
                          <html:option value="3">10000</html:option>
                        </html:select>
      

  6.   

    解决了,就是<html:select property="deptid"  value="deptid" style="width:150px;">
    多了个value="deptid" 。。 onray(39度) :
    就是rfq_MaterialQueryForm.setPriceunit("0");就可以了,不用set form的