我有一个从MySQL查询返回的小行列表,我想在MVC视图中显示。 我很难让视图发挥作用。在我最初的DAO中
return this.jdbcTemplate.queryForList(queryCohort);
我会这样做。这似乎是一个非常标准的查询。无论如何,我把它改成了
List<Map<String, Object>> graduates = this.jdbcTemplate.queryForList(queryCohort);
return graduates;
遵循这个过程。在我的控制器中,我有
List<Map<String, Object>> graduates = awardRecipientDAO.getAwardRecipientCohort(cohort);
mav.addObject(graduates);
控制器代码如下:
ModelAndView mav = new ModelAndView("success");
mav.addObject("conferralDate", conferralDate);
List<Map<String, Object>> graduates = awardRecipientDAO.getAwardRecipientCohort(cohort);
mav.addObject(graduates);
return mav;
视图代码如下:
<c:forEach var="item" items="${graduates.graduates}">
<tr>
<td>${item.unique_code}</td>
<td>${item.surname}, {$item.givenname1}</td>
<td>${item.birth_date}</td>
<td>${item.standing_name}</td>
</tr>
</c:forEach>
没有输出到视图但我在日志中得到以下内容:
JstlView:[ 328] Added model object 'linkedCaseInsensitiveMapList'
of type [java.util.ArrayList] to request in view with name 'success'
INFO: JstlView:[ 328] Added model object 'conferralDate' of type [java.util.Date] to request in view with name 'success'
这与List<Map<String,Object>>
还是变量graduates
一致?日期与变量,类型和值匹配。
db输出看起来没问题 -
INFO: {unique_code=aa001380, surname=Mouse, givenname1=Michael, birth_date=1928-11-01, standing_name=Alumni}
有什么建议吗?