【发布时间】:2013-01-04 02:38:54
【问题描述】:
由于某种原因,这个
<sql:query dataSource="${ds}" sql="select user.id, user.name as userName, city, state, country, country.name as countryName, latitude, longitude, ip, last_visit from user, country where user.country = country.id order by last_visit desc limit 100" var="result"/>
<c:forEach var="col" items="${result.columnNames}">
${col},
</c:forEach>
产生
id, name, city, state, country, name, latitude, longitude, ip, last_visit,
这是错误的。我专门重命名了查询中的列。我不知道它是如何找到原始字段名称的。那么如何访问 user.name 的值呢? ${row.userName} 不起作用。
我正在使用 JSTL jstl-1.2.2。
【问题讨论】:
-
这确实有效,但我对此并不满意:
<c:forEach var="rows" items="${result.rowsByIndex}"> ${rows[1]}, ${rows[5]}<br> </c:forEach>