<action path="/productEdit" type="product.ProductEditAction" name="productForm" validate="true" parameter="method" input="/jsp/product/productEdit.jsp"> <forward name="editProduct" path="/jsp/product/productEdit.jsp" /> <forward name="toAllProducts" path="/productSearch.do?method=showAll" redirect="true"/> <forward name="manageResourceGroups" path="/jsp/product/manageResourceGroups.jsp"/> </action> <action path="/productSearch" type="product.ProductSearchAction" name="productForm" parameter="method"> <forward name="toAllProducts" path="/jsp/product/productSearch.jsp" /> </action>
上面是我们常见的struts配置文件,在两个action当中都配置了同样的一个ActionForm:productFrom。 当我们在productEdit.do处理当中,可以通过mapping.findForward("toAllProducts")转到productSearch.do当中来。
如果我们不写redirect,那么两者使用同一个request,那么是不是在productEdit.do中修改了productForm的值以后,productSearch.do处理就能看到呢?
答案是否定的
struts设计上认为ActionForm是用来jsp和Action之间进行传递的bean,不是用来在Action之间传递的数据对象!
那么,当我们有共享数据需求的时候,就只能在request或者session当中进行保存了。