Reputation: 1
I write this code in scala.html
to show the MySQL data in an HTML
table:
@for(a <- 1 to rowNum){
@rs.next()
<tr>
<td>@rs.getString("building_id")</td>
<td>@rs.getString("building_name")</td>
<td>@rs.getString("building_type")</td>
<td>@rs.getString("address")</td>
</tr>
It gives the following result:
true true true true true true true true true true
id name type address
1 The Floravale condo Westwood Avenue
2 building2 condo Jurong West Street 21
3 building3 hdb Jurong West Street 31
4 building4 hdb Jurong West Street 81
5 building5 hdb Jurong West Street 61
6 building6 hdb Jurong West Street 81
7 building7 hdb Kang Ching Road
8 building8 hdb Kang Ching Road
9 building9 hdb Boon Lay Drive
10 building10 hdb Boon Lay Place
How can I hide the true
as the output of @rs.next()
?
Or are there other ways to display data? Thanks!
Upvotes: 0
Views: 57
Reputation: 2796
As commented, it is probably that true
is being returned, and therefore appearing as a result. A more typical usage would be to collect your rows in a List passed to the view, often in it's own case class (say Building
), then use a map:
@buildings.map { building =>
<td>building.id</td>
<td>building.name</td>
...
}
Upvotes: 1