struts跨Form与页面使用Form中的属性

首先我们有三个Action,每个Action自带一个相互独立的ActionForm,结构如下图

struts跨Form与页面使用Form中的属性
index.jsp,one.jsp,two.jsp,three.jsp 分别带有一个<html:form>提交三个属性,并且显示前面JSP提交的三个属性值,如one.jsp提交三个属性到"/two",并且显示index.jsp提交并通过oneAction处理的三个属性
 
    <body>
    <html:form action="/two">
     This one page. <br>
     name<html:text property="name"/>
     password<html:text property="password"/>
     testStriong<html:text property="testString"/>
     <html:submit/>
     !!!out:!!!
     <bean:write name="oneForm" property="name"/>
     <bean:write name="oneForm" property="password"/>
     <bean:write name="oneForm" property="testString"/> 
     </html:form>
   </body>
 
这样每个Form中就都存储了上个页面提交的值,如果要从第三个Action中使用第一个Form的值,如下:
public ActionForward execute(ActionMapping mapping, 
                                                 ActionForm form,
                                                 HttpServletRequest request, 
                                                 HttpServletResponse response) {

   ThreeForm threeForm = (ThreeForm) form;

   //OneForm oneForm=(OneForm)form;
   //String str=(String) s.getAttribute("name");
   //threeForm.setName(str);
  //这样写会造成ClassCastException
   HttpSession session=request.getSession();
   OneForm oneForm=(OneForm)session.getAttribute("oneForm");
   threeForm.setName(oneForm.getName());
   return mapping.findForward("three");
}