ユーザーが sql クエリを起動して、その結果を grails ビュー ページに表示したいと考えています。
私のQueryController.groovy
は
def query(){
def headers = null; //["id","name"]
Sql sql = new Sql(dataSource)
def rowResults = sql.rows(params.query) //GroovyRowResult
rowResults.eachWithIndex { row, index->
if (headers == null) {
headers = row.keySet()
}
}
[headers : headers, resultList: rowResults, total : rowResults.size() ]
}
Grails ビュー ページ ( query.gsp
) で、
<table class="table table-striped">
<thead>
<tr>
<g:each in="${headers}" var="header">
<g:sortableColumn property="header" title="${header}" />
<th></th>
</g:each>
</tr>
</thead>
<tbody>
<g:each in="${resultList}" var="row">
<tr>
<g:each status="counter" in="${row}" var="val">
<td>${val}</td>
</g:each>
</tr>
</g:each>
</tbody>
</table>
ビュー内の<td>${val}</td>
パーツは期待どおりに機能していませid=1
ん1
。そこに値だけを表示したい。
小さな問題かもしれませんが、修正する必要があります。
ありがとう。