我有一个如下所示的休眠代码,它返回单个实体类:
SQLQuery query =
session.createSQLQuery("select * from Employee");
query.addEntity(Employee.class);
List<Employee> emplist= query.list();
对于上面的代码,我的 Jstl 工作代码是:
<c:choose>
<c:when test="${requestScope.size!=0}">
<table border="1">
<tr>
<th>
EmployeeName
</th>
<th>EmployeeDepartment</th>
</tr>
<c:forEach items="${requestScope.absentlist}" var="emps">
<tr>
<td><c:out value="${emps.empno}"/></td>
<td><c:out value="${emps.empname}"/></td>
</tr>
</c:forEach>
但我的要求是为返回两个实体的休眠编写一个 jstl 代码
这是我的休眠代码:
SQLQuery query = session
.createSQLQuery("CALL AbsentReportproc(:_fromdate,:_todate)");
query.addEntity(Master.class);
query.addEntity(DateRange.class);
query.setParameter("_fromdate", "2012-12-03");
query.setParameter("_todate", "2012-12-04");
List<RecordSet> obj = query.list();
Iterator it=obj.iterator();
while(it.hasNext())
{
Object[] obj1 = (Object[]) it.next();
for (int i = 0; i < obj1.length; i++) {
RecordSet set=(RecordSet)obj1[i];
if(set instanceof Master){
System.out.println("Employee Code"+((Master) set).getEmpcode());
System.out.println("Employee Dept"+((Master) set).getDept());
System.out.println("Employee Name"+((Master) set).getEmpname());
}
if(set instanceof DateRange){
System.out.println("AbsentDate"+((DateRange) set).getDdate());
}
}
}
任何人都可以提供 JSTL 代码来在 jsp 页面上显示上述结果吗?