1
使用JSTL和Spring时遇到问题......它不允许我遍历我的列表。ForEach不适用于列表
这是我的看法......
<html>
<body>
// This prints fine
<h2>${profileList}</h2>
// this doesn't
<c:forEach var="x" items="${profileList}" >
<c:out value="${x}"/>
<br />
</c:forEach>
</body>
</html>
这里是我的控制器......
@RequestMapping("/")
public ModelAndView welcomeHandler() throws Exception {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
List profileList = analyticsManager.getProfiles();
ModelAndView model = new ModelAndView("HelloWorldPage");
model.addObject("msg", Integer.toString(profileList.size()));
model.addObject("profileList", profileList);
return model;
}
这里是构建列表中的代码...
public List<String> getProfiles() throws Exception {
List profileList = new ArrayList<String>();
Profiles profiles = analytics.management().profiles().list("~all", "~all").execute();
for (Profile profile : profiles.getItems()) {
profileList.add(profile.getId());
}
return profileList;
}
宾果!谢啦! – gshauger 2012-03-20 20:14:17