隐藏HTML文件中的Java输出

时间:2015-10-11 06:05:26

标签: html scala playframework-2.0

我在scala.html中编写此代码以在HTML表中显示MySQL数据:

@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>

它给出了以下结果:

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

如何将true隐藏为@rs.next()的输出? 还是有其他方式来显示数据?谢谢!

1 个答案:

答案 0 :(得分:1)

如评论所述,可能会返回true,因此会出现。更典型的用法是在传递给视图的List中收集行,通常在它自己的case类(比如Building)中,然后使用map:

@buildings.map { building =>
  <td>building.id</td>
  <td>building.name</td>
  ...
}