2012-10-12 24 views
0

我使用struts 1.3 + spring 2.5 + hibernate 3.如何使用struts在一个页面中加载两个数据表?

我有两个表:类别和产品。

使用标签逻辑从类别加载数据。

<logic:iterate id="cat" name="catList"> 
    <bean:write name="cat" property="catName" /> 
</logic:iterate> 

但是当我再次使用标签逻辑来加载从产品数据在同一页

<logic:iterate id="pro" name="proList"> 
    <bean:write name="pro" property="proName" /> 
</logic:iterate> 

它的错误,并抛出异常:< <找不到豆:在任何范围内“PROLIST”> >

我该如何解决?我想在一个页面中从数据库加载两个数据表。请帮帮我。

+0

请分享您的操作代码,在那里你已填充PROLIST和catList –

回答

1

你的Action类应该有这样的代码,我想你错过了在请求中添加proList。

试试下面的代码

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) {   

    List<Category> catList = db.getCategory();   
    List<Product> proList = db.getProduct();   

    request.setAttribute("proList", proList);  
    request.setAttribute("catList ", catList);  
    return mapping.findForward("success"); 
} 
+0

感谢。我错过了列表 proList = db.getProduct(); request.setAttribute(“proList”,proList); – furyfish

相关问题