我有一个控制器和一个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>
我不允许这样使用'它'吗?或者有什么明显的东西我不见了?
答案 0 :(得分:2)
http://www.grails.org/Views+and+Layouts
<html>
<head>
<title>Book list</title>
</head>
<body>
<h1>Book list</h1>
<table>
<tr>
<th>Title</th>
<th>Author</th>
</tr>
<g:each in="${books}">
<tr>
<td>${it.title}</td>
<td>${it.author}</td>
</tr>
</g:each>
</table>
</body>
</html>