以前写都是<one-two-many 配置去级联现在换了种写法 不去配置 直接写多表HQL 然后返回对象数组!但报错了,大家帮小弟看下Action里的 String hql = "FROM Account a ,Department d where a.id=d.accountId";
Query query = getSession().createQuery(hql);
List li = query.list();
for(int i=0;i<li.size();i++){
Object[] objects = (Object[])li.get(i);
request.setAttribute("obj",objects);
}
return mapping.findForward("kk");页面上的 <c:choose>
<c:when test="${obj!=null}">
<c:forEach items="${obj}" var="accou">
<tr class=datagrid_itemstyle_normal align=middle
nowrap="nowrap">
<td height="27" valign="top" >
${accou[0].id}
</td>
</tr>
</c:forEach>
</c:when>
<c:otherwise>
<%
response.sendRedirect(request.getContextPath()
+ "/views.do?method=all_acount");
%>
</c:otherwise>
</c:choose>异常信息是 Property '0' not found on type dao.Account
Property '0' not found on type dao.Account说没有找到这个Account 请问该怎么改下,我第一次这样写,最好能详细点,先谢谢了
Query query = getSession().createQuery(hql);
List li = query.list();
for(int i=0;i<li.size();i++){
Object[] objects = (Object[])li.get(i);
request.setAttribute("obj",objects);
}
return mapping.findForward("kk");页面上的 <c:choose>
<c:when test="${obj!=null}">
<c:forEach items="${obj}" var="accou">
<tr class=datagrid_itemstyle_normal align=middle
nowrap="nowrap">
<td height="27" valign="top" >
${accou[0].id}
</td>
</tr>
</c:forEach>
</c:when>
<c:otherwise>
<%
response.sendRedirect(request.getContextPath()
+ "/views.do?method=all_acount");
%>
</c:otherwise>
</c:choose>异常信息是 Property '0' not found on type dao.Account
Property '0' not found on type dao.Account说没有找到这个Account 请问该怎么改下,我第一次这样写,最好能详细点,先谢谢了
<td height="27" valign="top" >
${accou.id}
</td>
<td height="27" valign="top" >
${accou.id}
</td>
Query query = getSession().createQuery(hql);
List li = query.list();
request.setAttribute("obj",li); return mapping.findForward("kk"); forEach就可以迭代list的啊
直接 request.setAttribute("obj",objects) 就可以勒撒forEach标签可以迭代输入list的。