本人使用struts结构编程,但是不知道如何在一个Action中访问多个java bean。谢谢指点!! 例如有两个bean: AgentInfo、AgentDetail, 
一个Action:SetAgent,输入页面为main.jsp 
如何在实现在SetAgent中访问上面的两个bean?具体如何实现?

解决方案 »

  1.   

    直接把包引用近来就可以用啦.还要别的吗?import .....就好了啊
      

  2.   


    import com.*.AccountBO;
    import com.*.AuctionBO;
    import com.*.FundBO;import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionForward;public class testAction extends IMAction {  /**
       * @param mapping
       * @param form
       * @param request
       * @param response
       * @return ActionForward
       * @throws Exception
       */
      public ActionForward Fund(ActionMapping mapping, ActionForm form,
                                      javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse
                                      response) throws Exception {
          testForm pForm = (testForm  form;
          if (pForm == null) {
            pForm = new testForm();
          }
            AccountBO abo = new AccountBO();
            AuctionBO bbo = new AuctionBO() ;
            FundBO    fbo = new FundBO(); 
            ......
            ......
          String forwardName = "open";
          return (mapping.findForward(forwardName));
        } catch (Exception e) {
          return (mapping.findForward("errorPage"));
        }
      }
      

  3.   

    我的意思是怎么在action中,同时读取两个bean中的属性值?在前面的逻辑中  对这两个bean中的属性赋值了!现在要在SetAgent中访问该bean的属性值!
    如果直接import进来,再重新定义实例,那这些属性值不就重新初始化咯?不能再读取该bean中以前设置的值了!!