日期:2014-05-18  浏览次数:20655 次

如何在Struts结构中的Action中访问多个java bean?
本人使用struts结构编程,但是不知道如何在一个Action中访问多个java   bean。谢谢指点!!  

例如有两个bean:   AgentInfo、AgentDetail,  
一个Action:SetAgent,输入页面为main.jsp  
如何在实现在SetAgent中访问上面的两个bean?具体如何实现?


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

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 "));
}
}