我觉得这种做法好像不行。好像ActionForm在转到下个画面时,会自动被释放掉的。没有正是过:)

解决方案 »

  1.   

    忘了说了,好像jsp2.jsp用<%=(String)request.getAttribute("name")%>就可以了吧。
      

  2.   

    需要把得到的值传到FromBean中,然后用struts中的<bean:write name="XXX" property="XXX">就可以取到值了
      

  3.   

    在你的action里 
    System.out.println(f.getMail());
    能不能输出值到控制台啊
      

  4.   

    在jsp里用form.getName()当然是null
    应该在Action用httpServletRequest.setAttribute("name",form.getName());
    得到Name的值再放到Attribute里,actionMapping.findForward("jsp2")转到jsp2
    <%=(String)request.getAttribute("name")%>得到
      

  5.   

    对了Action里别忘了设
    TestForm form = (TestForm) actionForm;
      

  6.   

    就这么说也说不清楚
    楼主还是查查liuxiaowei那个JBuilder8实战Struts的例子吧
      

  7.   

    <%TestForm form=(TestForm)request.getAttribute("form");%>
    肯定是不行!因为你根本没有把testForm存到request中!除非...
    request.setAttribute(mapping.getAttribute(), form);
    ---------------------------------------------我学习了struts很长时间了.感觉必须得学习example然后,大胆的改example.
      

  8.   

    struts会自动将ActionForm放在ActionMapping的scope中,你不需要再
    setAttribute(),所以:String attribute = mapping.getAttribute();
    ActionForm instance = null;
    HttpSession session = null;
    if ("request".equals(mapping.getScope())) {
           instance = (ActionForm) request.getAttribute(attribute);
    } else {
           session = request.getSession();
           instance = (ActionForm) session.getAttribute(attribute);
    }
      

  9.   

    struts会自动将ActionForm放在ActionMapping的scope中?
    不对吧。
    根据我的使用经验是由struts-config.xml里面action决定
        <action    path="/editSubscription"
                   type="org.apache.struts.webapp.example.EditSubscriptionAction"
              attribute="subscriptionForm"
    <!--          name="subscriptionForm"-->
                  scope="request"
               validate="false">
          <forward name="failure"              path="/mainMenu.jsp"/>
          <forward name="success"              path="/subscription.jsp"/>
        </action>注意上面这个action
    如果使用name,struts就会自动新建actionform
    如果使用attribute, 就得自己新建了
      

  10.   

    action的attribute默认等于name。
    没有自动新建或自己新建ActionForm的说法,全部由系统自动创建,创建完
    之后保存在scope中,请去看源代码