gpt4 book ai didi

search - 无此类属性:类test3.ExampleController的exampleInstance

转载 作者:行者123 更新时间:2023-12-02 14:45:18 25 4
gpt4 key购买 nike


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()]
}
}

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

最佳答案

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

关于search - 无此类属性:类test3.ExampleController的exampleInstance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13001082/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com