【发布时间】:2010-09-07 23:42:18
【问题描述】:
我有一个控制器和一个 gsp。我继续尝试构建项目,但在我的 gsp 上收到问题。
它告诉我“当前作用域已经包含一个名为它的变量”
<html>
<head>
<title>Book Collector</title>
<meta name="layout" content="main" />
</head>
<body>
<h1>Book Editor</h1>
<table>
<tr>
<th>Book Name</th>
<th>Author</th>
<th>Page Number</th>
<th>Vendor</th>
<th>Date Scanned</th>
<th>Date Read</th>
</tr>
<% bookList.each { it -> %>
<tr>
<td><%= it.bookName %></td> //this is where the error starts
<td><%= it.author %></td> //error (it)
<td><%= it.pageNumber %></td> //error (it)
<td><%= it.lastScan %></td> //error (it)
<td><%= it.lastRead %></td> //error (it)
<% } %>
</tr>
</table>
</body>
</html>
我不能这样使用“它”吗?还是有什么明显的我遗漏的东西?
【问题讨论】:
-
因为您刚刚开始,我建议您从 www.grails.org 开始
-
但你是对的......你不能使用'it ->',但如果你省略'it ->',我相信它会起作用 - 但它不是真正的 Groovy/Grails 方式这样做!