1

领域

class Example {
   String title
   Date releaseDate
   String author
   Boolean paperback
   static constraints = {
   }
}

控制器

class ExampleController {
   def scaffold = true

   def search = {
      exampleInstance = Example.findAllByTitleIlike("${params.q}%",[max:10, offset:0, sort:"title", order:"asc"])

      redirect(action: "list",params)
      return
   }

   def list = {
      params.max = Math.min(params.max ? params.int('max') : 10, 100)
      [exampleInstanceList: Example.list(params),
       exampleInstanceTotal: Example.count()]
   }
}

看法

<div id="search">
   <g:form url='[controller: "example", action: "search"]' id="search" name="search" method="get">
      <g:textField name="q" value="${params.q}" />
      <input type="submit" value="Find" />
   </g:form>
</div>

请帮助我是如何

Error URI /test3/example/search Class groovy.lang.MissingPropertyException
Message No such property: exampleInstance for class: test3.ExampleController
4

1 回答 1

1

使用渲染而不是重定向并传递列表页面所需的所有模型。
def search = {
def exampleInstance= Example.findAllByTitleIlike("${params.q}%",[max:10, offset:0, sort:"title", order:"asc"])
render( view:list, model:[ exampleInstance:exampleInstance, params:params ] )

于 2012-10-21T19:07:29.747 回答