我的原意是想在action中从数据库中检索出信息填充到action form中,然后前台页面表单
的<html:text..等标签就可以获取值了.请问在action中怎样手动填充action form?

解决方案 »

  1.   

    //普通的formbean
    f.setXX(rs.getString("xx"));
    or
    //dynamicformbean
    f.set("xx",rs.getString("xx"));
      

  2.   

    Student stu=new Student();
    stu.setNu("00001");
    stu.setName("张海");
    StudentForm stuForm=(StudentForm)form;
    form.setStudent();
    -------------------------
    你的actionform中这样定义:
    public class StudentForm extends ActionForm {
        private Student student=new Student();
    }
    jsp:
    <html:text property="student.name"  />
      

  3.   

    >>>//form.setStudent();
    stuForm.setStudent(stu);
      

  4.   

    public class StudentForm extends ActionForm {
        private Student student=new Student();
        .......get,setStudent方法
    }
      

  5.   

    不明白.请说清楚点,在action要怎么样做才能使前台页面HTML标签访问的Action Form中有数据?是下面这样吗?
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    CorpForm corpForm = (CorpForm) form;
                      ...
                      corpForm.set();
                      ....
                      form=corpForm;
    return mapping.findForward("modify");
    }
      

  6.   

    不过这句
    form=corpForm;
    是画蛇添足了
      

  7.   

    哎,还是我自己琢磨出来了.正确的应该这样做:
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    CorpForm corpForm = (CorpForm) form;
                      ...
                      corpForm.set();
                      ....
                      request.setAttribute("corpInfoForm", corpForm);//corpInfoForm必须是struts-config.xml中设置的名称
    return mapping.findForward("modify");
    }
    这样前台页面的struts标签中就有数据了
      

  8.   

    request.setAttribute("corpInfoForm", corpForm);//这句话多余
      

  9.   

    struts-config.xml中你设置的form的scope是什么?