1

我有一个控制器和一个 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>

我不能那样使用“它”吗?或者有什么明显的我想念的吗?

4

1 回答 1

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>
于 2010-09-07T23:47:19.683 回答